<?php
session_start();
include('db_connection.php');

if (isset($_SESSION['student_id'])) {
    $studentId = $_SESSION['student_id'];

    // OPTIONAL: if you later add online_status to students table
    // $stmt = $conn->prepare("UPDATE students SET online_status = 'offline' WHERE student_id = ?");
    // if ($stmt) {
    //     $stmt->bind_param("i", $studentId);
    //     $stmt->execute();
    // }
}

// Destroy session securely
$_SESSION = [];
session_destroy();

// Redirect
header("Location: student_login.php");
exit();
?>