17 lines
359 B
PHP
17 lines
359 B
PHP
<?php
|
|
session_start();
|
|
|
|
if (!isset($_SESSION['user_id'])) {
|
|
header("Location: login.php");
|
|
exit;
|
|
}
|
|
|
|
// Optional: Role-based access control
|
|
function require_role($role) {
|
|
if ($_SESSION['role'] !== $role) {
|
|
// Redirect to a generic dashboard or an error page
|
|
header("Location: login.php?error=unauthorized");
|
|
exit;
|
|
}
|
|
}
|
|
?>
|