<?php declare(strict_types=1); if (!defined('DASHBOARD_ROOT')) { http_response_code(403); exit('Direct access denied.'); } $adminId = $_SESSION['admin_id'] ?? null; $reason = $_POST['reason'] ?? $_GET['reason'] ?? 'manual'; if ($adminId) { Events::record(Events::CAT_AUTH, 'logout', 'admin_user', $adminId, ['reason' => $reason]); AuditLogger::log('logout', 'admin_user', $adminId, ['reason' => $reason]); } $_SESSION = []; if (ini_get("session.use_cookies")) { $params = session_get_cookie_params(); setcookie(session_name(), '', time() - 42000, $params["path"], $params["domain"], $params["secure"], $params["httponly"] ); } session_destroy(); header('Location: login.php?logged_out=1'); exit; 