function redirect_login_pf() { /* the idea here is to redirect to the login or portfolio selection page when the cookie doesn't contain a valid username or portfolio. This will stop someone from opening a browser and getting some page other than the login page */ global $scramble_names; session_start(); $login_page = "/login.php"; $portfolio_page = "/portfolios.php"; $URI = $_SERVER['REQUEST_URI']; // if a username isn't set, redirect to the login page if (!isset($_SESSION['username'])) { // don't redirect if we're already heading for it if ($URI != $login_page) { header("Location: {$login_page}"); exit; } } elseif (!isset($_SESSION['pfid'])) { // don't redirect if we're already heading for it if ($URI != $portfolio_page) { header("Location: {$portfolio_page}"); exit; } } if (isset($_SESSION['pfid'])) { $portfolio = new portfolio($_SESSION['pfid']); $scramble_names = $portfolio->symbNamesHidden(); } }