我創建了一個包含註銷按鈕的菜單的用戶頁面。當點擊該按鈕,用戶將被引導到一個註銷頁面下面的代碼:將自己的甜蜜時間銷燬的會話
session_start();
session_destroy();
include("/var/www/include/header.inc");
echo "<h>Logout Success</h>";
include("/var/www/include/menu.inc");
include("/var/www/include/footer.inc");
在menu.inc文件中的代碼編寫這樣的:
if(@$_SESSION['login'] == "yes")
{
// show expanded menu
}
else
{
// show normal menu
}
我是什麼現在看到註銷後是擴展菜單。看起來菜單包含的速度比會話可能被破壞的速度快,因此產生用戶仍然登錄的印象。有沒有辦法避免這種情況?
請務必檢查出[session_destroy(http://php.net/manual/en/function.session-destroy.php)(記住例子(和小字)有可能需要清理的cookies和其他信息)。 –