35535-vm/auth.php
Flatlogic Bot 01b406af83 1.1
2025-11-07 05:44:17 +00:00

19 lines
514 B
PHP

<?php
session_start();
function require_login($role = null) {
if (!isset($_SESSION['user_id'])) {
header('Location: login.php');
exit();
}
if ($role && $_SESSION['user_role'] !== $role) {
// Redirect to their own dashboard if they try to access a page for another role
if ($_SESSION['user_role'] === 'owner') {
header('Location: dashboard_owner.php');
} else {
header('Location: dashboard_client.php');
}
exit();
}
}