结束 PHPSESSID cookie 会话


ending PHPSESSID cookie sessions

我正在处理会话cookie。 每当我登录和注销时,浏览器仍然显示"PHPSESSID"。

以下是我用来构建的 php 文件的网址。我已经尝试过"Chrome和Firefox",但仍然有同样的问题。我确实知道这是一个很大的帮助请求,但我会非常感激它。

这些文件位于源文件夹中,其中包含以下文件。FG会员网站.phpmembersite_config.php

https://github.com/simfatic/RegistrationForm/tree/master/source

您必须在 https://github.com/simfatic/RegistrationForm/blob/master/source/include/fg_membersite.php 中取消设置会话 cookie ,函数注销

你可以这样做

<?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();
?>

代码示例取自 http://php.net/manual/en/function.session-destroy.php .您可以在 php.net 中找到更多信息

尝试在注销函数中遵循

session_unset();
session_destroy();
  1. 文件位于"源"文件夹内的"包含"文件夹中

  2. PHPSESSID 不一定与登录/注销有关,它只是用来处理会话。

正如你在这里看到的(https://github.com/simfatic/RegistrationForm/blob/master/source/include/fg_membersite.php,从第 172 行开始):

function LogOut()
{
    session_start();        
    $sessionvar = $this->GetLoginSessionVar();        
    $_SESSION[$sessionvar]=NULL;        
    unset($_SESSION[$sessionvar]);
}

此代码不会销毁会话,而只是取消设置 $_SESSION 数组中的变量。你可以使用

http://de2.php.net/manual/en/function.session-unset.php

其次

http://de2.php.net/manual/en/function.session-destroy.php

或者只需检查是否设置了 $_SESSION[$sessionvar] 并包含有效信息以查看用户是否已登录。这样,您可以保留可能包含其他有价值信息的会话。

抱歉我

以前的低质量答案

您可以使用下面的脚本在客户端轻松执行此操作。
(您可能需要更改路径和主机的值)

document.cookie = "PHPSESSID=; expires=Thu, 01 Jan 1970 00:00:00 UTC;path=/;host=localhost";