first commit
This commit is contained in:
19
CONTENT/ROOT_URI/Admin/auth.php
Normal file
19
CONTENT/ROOT_URI/Admin/auth.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
function require_login() {
|
||||
if (session_status() === PHP_SESSION_NONE) {
|
||||
session_start();
|
||||
}
|
||||
|
||||
// Prevent redirect loop for login page
|
||||
$current_path = $_SERVER['REQUEST_URI'];
|
||||
if (strpos($current_path, '/Admin/login') !== false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isset($_SESSION['user_id'])) {
|
||||
error_log("Redirecting to login.php from: $current_path");
|
||||
header("Location: /Admin/login");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user