<?php
require_once 'functions.php';

// Log logout activity (Assuming logActivity doesn't rely on the database column)
if (isset($_SESSION['user_id']) && $_SESSION['user_type'] === 'user') {
    logActivity('logout', 'User logged out', $_SESSION['user_id']);
}

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

// Destroy session cookie... (rest of your code remains the same)

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

// Destroy session cookie
if (isset($_COOKIE[session_name()])) {
    setcookie(session_name(), '', [
        'expires' => time() - 3600,
        'path' => '/',
        'secure' => true,
        'httponly' => true,
        'samesite' => 'Strict'
    ]);
}

// Destroy session
session_destroy();

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