id; } public static function check(?string $pwhash = null): bool { if (self::$authorizedUser !== null) return true; // get auth token if (!$pwhash) $pwhash = self::getToken(); if (!is_string($pwhash)) return false; // find session by given token $user = users::getUserByPwhash($pwhash); if (is_null($user)) { self::resetToken(); return false; } self::$authorizedUser = $user; return true; } public static function logout() { self::resetToken(); self::$authorizedUser = null; } }