一个网站的登录/注销会影响同一服务器上的另一个网站 [英] One website's login/logout affects another website on same server

查看:48
本文介绍了一个网站的登录/注销会影响同一服务器上的另一个网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为大学最后一年的项目开发两个动态网站.有时,在选项卡式浏览并同时在同一浏览器中打开两个网站时,会发生以下情况.

I am developing two dynamic websites for a Final Year College Project. Sometimes while tabbed browsing and having that both websites open in the same browser at the same time simultaneously, the following happens.

我使用会话来跟踪登录,并在最后(注销)销毁会话以注销系统;因为这个session_destroy();"我在localhost"上运行的另一个站点导致注销.

I use sessions for tracking the login and just destroy the session at the end (logout) to logout the system; because of this "session_destroy();" my another site running on "localhost" causes to logout.

如何克服这个问题?

不建议专门销毁会话变量(即unset($_SESSION['usename']).请提出合适的方法,我将不胜感激.☺

Don't suggest destroying session variables specifically (i.e. unset($_SESSION['usename']). Please suggest an appropriate way, I will be very thankful. ☺

推荐答案

确保每个网站的 cookie 路径设置正确:

Make sure the cookie paths are set properly per website:

session_set_cookie_params(600,'/website1/','localhost');
session_start();

http://uk3.php.net/手册/en/function.session-set-cookie-params.php

会话会将其路径参数默认为/",因此在本地工作时需要此覆盖.

Sessions will default their path parameter to just '/', hence this override being required when working locally.

这篇关于一个网站的登录/注销会影响同一服务器上的另一个网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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