14 lines
412 B
PHP
14 lines
412 B
PHP
<?php
|
|
if (session_status() === PHP_SESSION_NONE) {
|
|
session_start();
|
|
}
|
|
|
|
// Allow access to login, logout, and setup scripts without authentication
|
|
$allowed_pages = ['login.php', 'handle_login.php', 'logout.php', 'db/setup.php'];
|
|
$current_page = basename($_SERVER['PHP_SELF']);
|
|
|
|
if (!isset($_SESSION['user_id']) && !in_array($current_page, $allowed_pages)) {
|
|
header('Location: login.php');
|
|
exit();
|
|
}
|
|
?>
|