<?php
session_start();
include_once('includes/config.php');
if (isset($_SESSION['aid'])) {
    log_activity("Admin Logout", "Admin " . $_SESSION['username'] . " logged out.");
}
$_SESSION['alogin'] = "";
$_SESSION['login'] = "";
$_SESSION['aid'] = "";
$_SESSION['role'] = "";
session_unset();
session_destroy();

// Start a new session just to carry the logout message
session_start();
$_SESSION['errmsg'] = "You have successfully logged out";

header("location: ../admin-login.php");
exit();
?>