$loggedUser = $delegate->userGetById(abs(intval($_SESSION['userId']))); // If exists a logged user if (is_numeric($loggedUser->id)) { redirect('./editor.php'); } /** * [2] Cookie method * Check if user cookie is set */ } elseif (isset($_COOKIE['biscuit'])) { // Decode the cookie data $userCookie = packer($_COOKIE['biscuit'], PACKER_UNPACK); // Validate data if (validateEmail($userCookie['email'], null) and validateString($userCookie['password'], null, 1)) { // Load user as object, from SQL by id $loggedUser = $delegate->userGetByEmailAndCryptedPassword($userCookie['email'], $userCookie['password']); // If user is an object if (is_object($loggedUser)) { $_SESSION['userId'] = $loggedUser->id; redirect('./editor.php'); } } } ?> <!DOCTYPE html> <html> <?php $title = "Login | Diagramo"; $description = $title;