Flatlogic Bot 2332ec6934 1.0
2025-10-30 14:24:12 +00:00

25 lines
490 B
PHP

<?php
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
function is_logged_in() {
return isset($_SESSION['user_id']);
}
function require_login() {
if (!is_logged_in()) {
header("Location: login.php");
exit;
}
}
function require_role($role) {
require_login();
if ($_SESSION['user_role'] !== $role) {
// For simplicity, redirect to home. A 403 page would be better.
header("Location: index.php");
exit;
}
}