29 lines
485 B
PHP
29 lines
485 B
PHP
<?php
|
|
session_start();
|
|
|
|
// This is a simulation. In a real app, you'd validate against a database.
|
|
function login($email) {
|
|
$_SESSION['user'] = ['email' => $email];
|
|
header('Location: index.php');
|
|
exit();
|
|
}
|
|
|
|
function logout() {
|
|
session_destroy();
|
|
header('Location: login.php');
|
|
exit();
|
|
}
|
|
|
|
function check_auth() {
|
|
if (!isset($_SESSION['user'])) {
|
|
header('Location: login.php');
|
|
exit();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if (isset($_GET['logout'])) {
|
|
logout();
|
|
}
|