19 lines
514 B
PHP
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();
|
|
}
|
|
}
|