[英]PHP Session In 2 Web Application
I have 2 web application in my Notebook, now every I want to logout from one application, another application that still logged in will logout too. 我的笔记本中有2个Web应用程序,现在每个我要从一个应用程序注销,仍然登录的另一个应用程序也将注销。
In my App1, I using session : 在我的App1中,我使用session:
session_start();
$session = $_SESSION['username_a'];
and in App2 : 并在App2中:
session_start();
$session = $_SESSION['username_packing'];
Finally the logout PHP code like this : 最后注销PHP代码,如下所示:
session_destroy();
The condition : If I was logged in with 2 Application and then I logout 1 application, another 1 application will logout too. 条件:如果我使用2 Application登录,然后注销1个应用程序,则另外1个应用程序也将注销。
My question is : Is there anyway to prevent that (If log out 1 application, then another application will stay logged in)? 我的问题是:是否有防止出现这种情况的方法(如果注销1个应用程序,则另一个应用程序将保持登录状态)?
Session_destroy will destroy all session. Session_destroy将销毁所有会话。 You should unset specific session.
您应该取消设置特定的会话。 Like this:
像这样:
unset($_SESSION['username_a']); // on App 1
and 和
unset($_SESSION['username_packing']); // on App2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.