public static function run() { if (CookieController::cookieExists("session")) { if (($user = CookieController::refreshSessionCookie()) === false) { header("Location: home"); } else { ProfileView::show($user); } } else { header("Location: home"); } }
public static function run() { if (CookieController::cookieExists("session")) { if (($user = CookieController::refreshSessionCookie()) === false) { echo "<h1>No User Found</h1><hr/>"; LogInController::run(null); } else { DashboardView::show($user); } } else { LandingView::show(null); } }
include "../includer.php"; $params = array("firstName" => "John", "lastName" => "Cena", "email" => "*****@*****.**", "handle" => "johnCena", "about" => "Wrestling Champion"); $user = new User($params); $user->resetErrors(); echo "<h1>setSessionCookie():<hr/>"; if (!CookieController::setSessionCookie($user)) { echo "<h3>Failure: returned false</h3>"; } elseif (is_null($_COOKIE) || !isset($_COOKIE["session"])) { echo "<h3>Failure: \$_COOKIE is null or session is not set</h3>"; } else { echo "<h3>Success</h3>"; } echo "<h1>readSessionCookie():<hr/>"; if (!($user = CookieController::readSessionCookie($user))) { echo "<h3>Failure</h3>"; } elseif (empty($user->getFirstName())) { echo "<h3>Failure</h3>"; } else { echo "<h3>Success</h3>"; } echo "<h1>refreshSessionCookie():<hr/>"; if (!($user = CookieController::refreshSessionCookie($user))) { echo "<h3>Failure</h3>"; } elseif (empty($user->getFirstName())) { echo "<h3>Failure</h3>"; } else { echo "<h3>Success</h3>"; } ?> </body> </html>