getUID($username); if ($uid!==false && $db->getStatus($uid)>=3) $uid=false; if ($uid===false) { // user does not exist return 2; } $hash = $db->getPasswordHash($uid); if ($hasher->check($password, $hash)) { // success $_SESSION['uid'] = $uid; return 0; } else { // wrong password return 1; } } public static function isLoggedIn() { if ( isset($_SESSION['uid']) && ($_SESSION['uid']!='') ) { return $_SESSION['uid']; } else { return false; } } public static function logout() { $_SESSION['uid'] = ''; } }