<?php
/**
 * Admin Logout Handler
 * Digital Product Store
 */

require_once __DIR__ . '/../config/database.php';

// Log activity if admin was logged in
if (is_admin_logged_in()) {
    log_admin_activity($pdo, $_SESSION['admin_id'], 'logout', 'Admin logged out');
}

// Clear session
session_destroy();

set_flash_message('You have been logged out successfully.', 'success');
header('Location: ' . ADMIN_URL . '/login.php');
exit;
