如何在注销时取消设置特定的php会话 [英] How to unset a specific php session on logout
本文介绍了如何在注销时取消设置特定的php会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有2个站点.
在一个站点中,这是真的:
In one site this is true:
session_is_registered('site1sess')
在另一种情况下是这样:
and in the other one this is true:
session_is_registered('site2sess')
这些是我在登录时为用户提供的会话名称.我的问题是,当我从一个站点注销时,我也注销了另一个站点,因为我使用了:
Those are the session names I give users on login. My problem is that when I logout from one site, I also logout in the other one because I use:
session_destroy();
从site1或2中注销以删除所有会话变量的最佳方法是什么? 谢谢.
What is the best way to logout from site1 or 2 deleting all the session variables from it? Thank you.
推荐答案
对站点1或站点2特定的所有会话变量使用unset()
.
Use unset()
for all the session variables specific to either site 1 or 2.
unset($_SESSION['site1']);
//or
unset($_SESSION['site2']);
请注意,从PHP版本5.3.0开始不推荐使用session_is_registered
. 请参阅文档.
Just so that you know, session_is_registered
is deprecated as of PHP version 5.3.0. See docs.
这篇关于如何在注销时取消设置特定的php会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文