35430-vm/_auth.php
2025-11-02 20:07:39 +00:00

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();
}