This commit is contained in:
2023-08-12 01:39:17 +03:00
parent e92f792640
commit 79a031401a
13 changed files with 127 additions and 8 deletions

23
api/_auth.php Normal file
View File

@@ -0,0 +1,23 @@
<?php
require_once("_db.php"); //("api/_db.php");
session_start();
$LOGGED_IN = false;
if (isset($_SESSION["userid"])) {
// Check if user still exist
$s = $db->prepare("SELECT * FROM users WHERE id = ?");
$s->bind_param("s", $_SESSION["userid"]);
$s->execute();
if (!(bool)$s->get_result()->fetch_assoc()) {
session_unset();
session_destroy();
echo "user id does not exist";
die("user id used in session does not exist");
}
$LOGGED_IN = true;
}
?>