[英]ending PHPSESSID cookie sessions
我正在结束会话cookie。 每当我登录和注销时,浏览器仍然显示“ PHPSESSID”。
以下是我用来构建的php文件的网址。 我已经尝试过“ Chrome和Firefox”,但仍然存在相同的问题。 我确实知道这是一个很大的要求帮助,但是我会尽力而为。
这些文件与以下文件位于源文件夹中 。 fg-membersite.php Membersite_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();
这些文件位于“源”文件夹中的“包含”文件夹中
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/zh/function.session-unset.php
其次是
http://de2.php.net/manual/zh/function.session-destroy.php
为此,或者只是检查$ _SESSION [$ sessionvar]是否已设置并包含有效信息以查看用户是否已登录。这样,您可以保留可能包含其他有价值信息的会话。
对不起,我以前的回答质量很差
您可以使用以下脚本在客户端轻松完成此操作。
(您可能需要更改路径和主机的值)
document.cookie = "PHPSESSID=; expires=Thu, 01 Jan 1970 00:00:00 UTC;path=/;host=localhost";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.