19 lines
441 B
PHP
19 lines
441 B
PHP
<?php
|
|
/**
|
|
* auth_logout.php — Logout User
|
|
* Supports both AJAX (POST) and direct navigation (GET)
|
|
*/
|
|
session_start();
|
|
session_unset();
|
|
session_destroy();
|
|
|
|
// If called via AJAX (POST), return JSON
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
header('Content-Type: application/json');
|
|
echo json_encode(['success' => true]);
|
|
} else {
|
|
// If navigated directly, redirect to login
|
|
header('Location: login.html');
|
|
exit;
|
|
}
|