null, 'success' => null, 'notice' => null]; private static $userId = null; /** Returns the current login status * * The login status is stored in the session cookie. If it is not even set it means the login is invalid. * * @return bool true if the login status is true, false otherwise */ public static function isLoginValid() { return (isset($_SESSION) && array_key_exists('login', $_SESSION) && $_SESSION['login'] == true); } public static function getSessionUserId() { $userId = null; if (isset($_SESSION) && array_key_exists('user', $_SESSION) && array_key_exists('userId', $_SESSION['user'])) { $userId = $_SESSION['user']['userId']; } return $userId; } /** Remove all login data from the session data * * @return void */ public static function logout() { foreach (['login', 'user'] as $key) { unset($_SESSION[$key]); } } /** A little Box with the login status as html entity * * @return string htmlEntity showing the login status */ public static function htmlLoginStatus() { return '
' . $this->description . '
' . '| userName | lastLogins |
|---|---|
| ' . $userName . ' | ' . $lastLogins['lastLogins'][0] . ' |