正在销毁 $_SERVER 会话吗?
好吧,我没有使用任何会话变量,而是我的代码如下所示:
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="Enter your Twitter username and password:"');
header('HTTP/1.0 401 Unauthorized');
echo 'Please enter your Twitter username and password to view your followers.';
exit();
}
$username = $_SERVER['PHP_AUTH_USER'];
$password = $_SERVER['PHP_AUTH_PW'];
那么,我的问题是,当用户想要注销其(在本例中)twitter 登录凭据时,如何销毁此登录会话?
Okay so I'm not using any session variables, rather my code looks like this:
if (!isset($_SERVER['PHP_AUTH_USER'])) {
header('WWW-Authenticate: Basic realm="Enter your Twitter username and password:"');
header('HTTP/1.0 401 Unauthorized');
echo 'Please enter your Twitter username and password to view your followers.';
exit();
}
$username = $_SERVER['PHP_AUTH_USER'];
$password = $_SERVER['PHP_AUTH_PW'];
So, my question is, how can I destroy this login session when the user wants to sign out of their (in this case) twitter login credentials?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有办法破坏http认证登录服务器端。 这是这种登录形式的最大缺点之一。
There is no way to destroy an http authentication login server side. This is one of the biggest disadvantages of this form of login.
您所能做的就是发送另一个 401 标头。 浏览器通常会“忘记”旧值,弹出另一个用户/密码输入对话框,如果用户按下“中止”按钮,他们就会“注销”。
两个缺点:
编辑:并且已经得到回答,通过 PHP 进行 HTTP 身份验证注销
All you can do is to send another 401 header. The browser will usually "forget" the old value, pop up another user/pass input dialog and if users then press the "abort" button they are "logged out".
Two drawbacks:
edit: And has already been answered, HTTP authentication logout via PHP