<?php
session_start();
$redirect = "student-login.php"; // Default fallback

if (isset($_SESSION['admin_id'])) {
    $redirect = "admin-login.php";
} elseif (isset($_SESSION['instructor_id'])) {
    $redirect = "instructor-login.php";
} elseif (isset($_SESSION['student_id'])) {
    $redirect = "student-login.php";
}

session_unset();
session_destroy();
header("Location: $redirect");
exit();