11 lines
348 B
PHP
11 lines
348 B
PHP
<?php
|
|
session_start();
|
|
function isLoggedIn() { return isset($_SESSION['user_id']); }
|
|
function requireLogin() {
|
|
if (!isLoggedIn()) {
|
|
header('Location: /login.php?redirect=' . urlencode($_SERVER['REQUEST_URI']));
|
|
exit;
|
|
}
|
|
}
|
|
function currentUser() { return ['id' => $_SESSION['user_id'], 'username' => $_SESSION['username']]; }
|