簡體   English   中英

PHP會話未取消

[英]PHP Session not unsetting

我的PHP會話似乎尚未設置。 單擊注銷后返回主頁時,如果再次刷新頁面,則似乎重新登錄了。好像會話從未真正結束。 如果我離開頁面並重新訪問它,也會發生同樣的情況。 這是我的logout.php頁面:

<?php

// Initialize the session.
// If you are using session_name("something"), don't forget it now!
session_start();

// Unset all of the session variables.
$_SESSION = array();

// If it's desired to kill the session, also delete the session cookie.
// Note: This will destroy the session, and not just the session data!
if (ini_get("session.use_cookies")) {
    $params = session_get_cookie_params();
    setcookie(session_name(), '', time() - 42000,
        $params["path"], $params["domain"],
        $params["secure"], $params["httponly"]
    );
}

// Finally, destroy the session.
session_destroy();

header("Location: index.php");

?>

我真的不知道為什么要這么做,任何幫助都將不勝感激。 如果您需要更多信息,我很樂意提供一些信息。 謝謝!

您可以在logout.php中使用以下代碼

session_start(); 
unset($_SESSION['var_name']); //  delete just the session of va_name data
session_destroy(); // delete ALL session info/Data.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM