true, CURLOPT_POST => true, CURLOPT_HTTPHEADER => [ "apikey: " . SUPABASE_API_KEY, "Content-Type: application/json" ], CURLOPT_POSTFIELDS => json_encode([ "email" => $email, "password" => $password ]) ]); $response = curl_exec($curl); $data = json_decode($response, true); curl_close($curl); if (isset($data['access_token'])) { $_SESSION['access_token'] = $data['access_token']; $_SESSION['user_email'] = $email; header("Location: index.php"); exit; } else { $error = "Login failed. Please check your credentials."; } } // Handle logout if (isset($_GET['logout'])) { session_destroy(); header("Location: index.php"); exit; } // Check if logged in $loggedIn = isset($_SESSION['access_token']); ?>