任何想法为什么我必须单击退出按钮两次注销? [英] Any idea why I have to click the logout button twice to logout?

查看:96
本文介绍了任何想法为什么我必须单击退出按钮两次注销?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的logout.php代码

当我在我建立的网页上点击LOGOUT时,我必须点击两次才能注销,任何想法为什么?

When I click LOGOUT on my webpage I'm building, I have to click it twice to logout, any idea why?

推荐答案

首次注销,如果运行,销毁会话。下次您退出时, else 将被删除。

First time you log out, the if is run through, destroying the session. Next time you log out, the else is run through, removing the cookies.

查看 PHP - session_destroy ,有一个如何处理这个问题的示例。

Look at PHP - session_destroy, there's an example on how to handle this.

您也可以在一次运行中执行此操作,只需执行两个独立 if s

You can also do this in one run, just do two independent ifs

if (isset($_SESSION['user_id']) {
...
}

if (isset($_COOKIE['user_id']) {
...
}

这篇关于任何想法为什么我必须单击退出按钮两次注销?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆