<?php
session_start();

// Determine where to redirect based on user type
$redirectUrl = 'admin_login.php'; // Default: send to login

// If user is full admin, redirect to homepage
if (!empty($_SESSION['is_admin'])) {
    $redirectUrl = 'index.php'; // or wherever admins should go after logout
}

// If user is sub-admin, redirect to admin_login.php (they need to login again)
if (!empty($_SESSION['is_subadmin'])) {
    $redirectUrl = 'admin_login.php';
}

// Clear all session variables
$_SESSION = [];

// Destroy the session
session_destroy();

// Redirect to appropriate page
header('Location: ' . $redirectUrl);
exit;
?>
