if (session_status() === PHP_SESSION_NONE) { session_start(); } // If the including page already set $is_logged_in, respect it. if (!isset($is_logged_in)) { $is_logged_in = !empty($_SESSION['caf_logged_in']) && $_SESSION['caf_logged_in'] === true && !empty($_SESSION['caf_user_id']); } $current_page = basename($_SERVER['PHP_SELF'] ?? ''); /* * Build ?ret= query for Login/Register links. * * Priority: * 1. Preserve an existing ?ret= in the URL (so users don't lose it). * 2. Otherwise, if we're not already on login/register/logout, * encode the current URL so the user returns here after login. * 3. Otherwise, no ?ret=. */ $caf_ret_query = ''; if (!empty($_GET['ret'])) { $caf_ret_query = '?ret=' . urlencode($_GET['ret']); } elseif (!in_array($current_page, ['login.php', 'logout.php', 'register.php'], true)) { $caf_current_uri = $_SERVER['REQUEST_URI'] ?? '/'; $caf_ret_query = '?ret=' . urlencode(base64_encode($caf_current_uri)); } ?>

Cash a Friend

Login

?>