<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
session_start();
include "db.php"; // Include database connection file

// Check if the user is logged in
if (isset($_SESSION['username']) && $_SESSION['username'] !== '') {
    // Unset all session variables
    session_unset();
    
    // Destroy the session
    session_destroy();
    
    // Redirect to the login page
    header("Location: index.php");
    exit(); // Make sure no further code is executed after redirect
} else {
    // If not logged in, redirect to login page
    header("Location: index.php");
    exit();
}
?>
