<?php
require_once 'config.php'; // Database connection ke liye

// **NAYA LOGIC: Logout time record karein**
if (isset($_SESSION['session_log_id'])) {
    $session_log_id = $_SESSION['session_log_id'];
    $logout_time = date('Y-m-d H:i:s');
    
    $stmt = $conn->prepare("UPDATE user_sessions SET logout_time = ? WHERE id = ?");
    $stmt->bind_param("si", $logout_time, $session_log_id);
    $stmt->execute();
    $stmt->close();
}

// Session se sabhi variables ko unset karein
$_SESSION = array();

// Session ko destroy karein
session_destroy();

// Login page par redirect karein
header("location: login.php");
exit;
?>