User restore session

This commit is contained in:
2023-09-04 16:15:44 +00:00
parent a761df59a7
commit 8eec1a97ba
37 changed files with 130 additions and 195 deletions

View File

@@ -152,4 +152,21 @@ class Login
session_start();
session_destroy();
}
}
private static function is_logged(): bool
{
return isset($_SESSION["user"]);
}
// get the user from the session (if not )
public static function get_user(): Login
{
if (Login::is_logged()) {
$user = unserialize($_SESSION["user"]);
return $user;
}
header("Location: /");
exit();
}
}