34772-vm/includes/auth.php
Flatlogic Bot 7181333ac7 version2
2025-10-07 23:57:03 +00:00

18 lines
420 B
PHP

<?php
function check_login() {
if (!isset($_SESSION['user_id'])) {
header("Location: login.php");
exit;
}
}
function check_role($role) {
if ($_SESSION['user_role'] !== $role) {
// Redirect to their own dashboard if they try to access another role's page
$dashboard = $_SESSION['user_role'] . '_dashboard.php';
header("Location: $dashboard");
exit;
}
}
?>