简体   繁体   English

PHP会话在不同的文件夹

[英]PHP Session in different folder

Problem PHP session in different folder. 问题PHP会话在不同的文件夹。

I have problem with PHP session. 我的PHP会话有问题。

There are two folder: A AND B When I already logged in Folder A then i click link access to folder B when come to index.php file in Folder A. It doesn't to recognize session state. 有两个文件夹:A和B当我已经登录了文件夹A时,当我进入文件夹A中的index.php文件时,我单击了对文件夹B的链接访问。它无法识别会话状态。

PHP Code: PHP代码:

if(!isset($_SESSION))
{   
    session_cache_expire (21900);
    $cache_expire = session_cache_expire();  
    session_start();
}

How can i check session redirect ? 如何检查会话重定向?

f(!isset($_SESSION['a'])){
    redirce to a
}

f(!isset($_SESSION['b'])){
    redirce to b
}

Best Regards 最好的祝福

Try this: 尝试这个:

if(!session_id()) {
    session_start();
    session_cache_expire (21900);
}

Check your phpinfo() and look for suhosin. 检查您的phpinfo()并查找suhosin。 If it is installed then you should disable it in order to let sessions be shared betwen different paths. 如果已安装,则应禁用它,以便在不同路径之间共享会话。

This is happening because the validity scope of the PHPSESSIONID cookie is restricted to the folder A , so in folder B it doesn't get fed the same cookies. 发生这种情况是因为PHPSESSIONID cookie的有效性范围仅限于文件夹A ,因此在文件夹B中不会得到相同的cookie。 You have to change that to the parent folder containing both A and B . 您必须将其更改为包含AB的父文件夹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM