<?php
session_start();
session_destroy();

$timeout = $_GET['timeout'] ?? 0;
if ($timeout) {
    echo "<script>alert('You have been logged out due to time limit.'); window.location='index.php';</script>";
} else {
    echo "<script>alert('You have successfully logged out.'); window.location='index.php';</script>";
}
exit;
