MySIte立即注销第二个请求 [英] MySIte immediately getting logged out for 2nd request
问题描述
我是php的新手。我面对会话的问题。我的意思是,在我登录后,我点击网站上的任何链接,它立即注销。不知道为什么。
在Chrome控制台中:我输入为:document.cookie,它显示我,然后我明白,cookie是以某种方式被立即删除或一些其他问题。
以下2个网站存在此问题。
我们有类似的网站:
www.mysite.site1.com/folder1
www.mysite.site2.com/folder2
以下是我的代码MySite.com/folder1
function MySession(){
$ params = session_get_cookie_params();
session_set_cookie_params($ params ['lifetime'],'/ v / folder1');
session_start();
}
function clear()
{
$ _SESSION = array();
session_destroy();
}
下面是我的代码MySite.com/folder2
function MySession(){
$ params = session_get_cookie_params
session_set_cookie_params($ params ['lifetime'],'/ v / folder2');
session_start();
}
function clear()
{
$ _SESSION = array();
session_destroy();
}
解决方案找到我的查询答案:
因为在我的情况下,我有2个文件夹ie。,www.mysite.com/folder1&& www.mysite.com/folder2,那么我们必须为'folder1'和
session_name('folder2')保留
session_name('folder1' folder2'
,否则两个文件夹共享相同的会话ID,因此用户自动登录到folder2(假设他已经登录了folder1)function Session(){
session_name('FOLDER_SID');
session_start();有关session_name的更多信息,请参阅:http://
}
$ b < //stackoverflow.com/a/7551430/4956785I am new to php. I am facing problem with sessions. I mean, after I get logged in and I click on any link in the website , its immediately getting logged out. Not sure why.
In chrome console: I entered as : document.cookie , it showing me "", then I got to understand that cookie is somehow getting deleted immediately or some other issue.
This problem exists for below 2 websites.
We have a websites like :
www.mysite.site1.com/folder1 www.mysite.site2.com/folder2
Below is my code of MySite.com/folder1
function MySession() { $params = session_get_cookie_params(); session_set_cookie_params($params['lifetime'], '/v/folder1'); session_start(); } function clear() { $_SESSION=array(); session_destroy(); }
Below is my code of MySite.com/folder2
function MySession() { $params = session_get_cookie_params(); session_set_cookie_params($params['lifetime'], '/v/folder2'); session_start(); } function clear() { $_SESSION=array(); session_destroy(); }
解决方案Well, I am able to find out answer for my query:
since in my case I have 2 folders ie., www.mysite.com/folder1 && www.mysite.com/folder2 , then we MUST keep
session_name('folder1') for 'folder1'
andsession_name('folder2') for 'folder2'
, otherwise both folders share the same session ID and so user gets logged in automatically in folder2 (assuming if he already got loggedin folder1)function Session() { session_name('FOLDER_SID'); session_start(); }
Regarding more info about session_name, here:
http://stackoverflow.com/a/7551430/4956785
这篇关于MySIte立即注销第二个请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!