Add includes/auth.php
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once __DIR__ . '/config.php';
|
||||
|
||||
function isLoggedIn(): bool
|
||||
{
|
||||
return isset($_SESSION['user']);
|
||||
}
|
||||
|
||||
function requireLogin(): void
|
||||
{
|
||||
if (!isLoggedIn()) {
|
||||
header('Location: login.php');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user