<?php
// admin/logout.php
if (session_status() === PHP_SESSION_NONE) session_start();

// Wipe all session data
$_SESSION = [];

// Delete session cookie
if (ini_get("session.use_cookies")) {
    $p = session_get_cookie_params();
    setcookie(
        session_name(), '',
        time() - 86400,
        $p['path'], $p['domain'],
        $p['secure'], $p['httponly']
    );
}

session_destroy();

header("Location: /webadmin/login.php?msg=logged_out");
exit;