Files
leonapp/admin/logout.php
2025-09-20 22:20:08 +08:00

37 lines
899 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
require_once '../config.php';
session_start();
// 销毁所有会话变量
$_SESSION = [];
// 如果使用了基于cookie的会话也需要删除cookie
if (ini_get("session.use_cookies")) {
$params = session_get_cookie_params();
setcookie(
session_name(),
'',
time() - 42000,
$params["path"],
$params["domain"],
$params["secure"],
$params["httponly"]
);
}
// 销毁会话
session_destroy();
// 使用Sweet Alert弹窗提示并跳转登录页
echo '<script src="/js/sweetalert.js"></script>';
echo '<script>document.addEventListener("DOMContentLoaded", function() {
Swal.fire({
title: "登出成功",
text: "您已安全登出系统",
icon: "success",
timer: 1500,
showConfirmButton: false,
target: document.body
}).then(() => { window.location.href = "login.php"; });
});</script>';
exit();