<?php
session_start();
session_destroy();

// Forward an optional redirect target so login.php can send the user
// back to where they logged out from (e.g. phone/index.html).
$redirect = trim((string)($_GET['redirect'] ?? ''));
$target = 'login.php';
if ($redirect !== '') {
    $target .= '?redirect=' . urlencode($redirect);
}
header('Location: ' . $target);
exit;
