<?php
session_start();

/* Capture where user logged out from */
$from = $_GET['from'] ?? '';

/* Destroy session */
session_unset();
session_destroy();

/* Start fresh session */
session_start();

/* Preserve redirect target */
if (is_string($from) && str_starts_with($from, '/')) {
    $_SESSION['post_logout_from'] = $from;
}

/* Redirect to login */
header('Location: /admin/login.php');
exit;
