guestbook/logout.php
Zhang Pu 06d21f90db init: guestbook v1.0.0 首次发布
- 加固版留言系统 / 磁盘清理助手
- MIT License
2026-11-02 11:12:15 +08:00

25 lines
573 B
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* 退出登录(POST + CSRF)
*/
declare(strict_types=1);
require_once __DIR__ . '/config.php';
if (is_post()) {
require_csrf();
}
$_SESSION = [];
if (ini_get('session.use_cookies')) {
$p = session_get_cookie_params();
setcookie(session_name(), '', [
'expires' => time() - 42000,
'path' => $p['path'],
'domain' => $p['domain'],
'secure' => $p['secure'],
'httponly' => $p['httponly'],
'samesite' => $p['samesite'] ?? 'Lax',
]);
}
session_destroy();
header('Location: login.php');
exit;