【发布时间】:2013-01-10 17:43:02
【问题描述】:
This is my code for logout.php
当我在我正在构建的网页上点击 LOGOUT 时,我必须点击两次才能注销,知道为什么吗?
【问题讨论】:
-
code sn-p 不足以调试为什么您的注销行为奇怪并在链接代码时使用codepad.viper-7.com 或pastebin.com,:))
标签: php html css web-services web
This is my code for logout.php
当我在我正在构建的网页上点击 LOGOUT 时,我必须点击两次才能注销,知道为什么吗?
【问题讨论】:
标签: php html css web-services web
您似乎同时使用了会话和 cookie,可能是为了“记住我”功能。但是,注销脚本一次只删除一个。
尝试删除else if中的else。
if (session exists)
{
destroy session
}
if (cookie exists)
{
delete cookie
}
【讨论】:
第一次注销时,if 会运行,从而破坏会话。下次您注销时,else 会运行,删除 cookie。
看看PHP - session_destroy,有一个关于如何处理的例子。
你也可以一次运行,只做两个独立的ifs
if (isset($_SESSION['user_id']) {
...
}
if (isset($_COOKIE['user_id']) {
...
}
【讨论】: