<?php
// logout_action.php

session_start();

// Unset all session variables
$_SESSION = array();

// Destroy the session
session_destroy();

// Remove cookies
setcookie('adminid', '', time() - 3600, '/');
setcookie('adminrole', '', time() - 3600, '/');
setcookie('adminname', '', time() - 3600, '/');

// Optional: store a session message for login page
session_start();
$_SESSION['message'] = [
    'type' => 'info',
    'text' => 'You have been logged out successfully.'
];

// Redirect to login
header("Location: index.php");
exit();
?>
