api/user/__admin_session.php and random tweaks

This commit is contained in:
2023-08-30 05:16:15 +03:00
parent 074ce120e9
commit ae719995ee
7 changed files with 44 additions and 11 deletions

View File

@ -21,7 +21,7 @@ function EndSession () {
$LOGGED_IN = false;
if (isset($_SESSION["userid"])) {
if (session_status() == PHP_SESSION_ACTIVE && isset($_SESSION["userid"])) {
// Check if user still exist
$s = $db->prepare("SELECT * FROM users WHERE id = ?");
$s->bind_param("s", $_SESSION["userid"]);
@ -32,10 +32,10 @@ if (isset($_SESSION["userid"])) {
die("user id used in session does not exist");
}
$LOGGED_IN = true;
} else {
if (session_status()) {
EndSession();
}
} elseif (session_status() == PHP_SESSION_ACTIVE && !isset($_SESSION["userid"])) {
echo "no userid, destroying session";
EndSession();
die("no userid in session");
}
?>