20 lines
459 B
PHP
20 lines
459 B
PHP
<?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();
|
|
}
|
|
}
|
|
|