PHP 5.3.3 - 在子目录中运行 session_start() 会杀死现有会话 [英] PHP 5.3.3 - running session_start() in subdirectory kills existing session

查看:43
本文介绍了PHP 5.3.3 - 在子目录中运行 session_start() 会杀死现有会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

自从我的虚拟主机升级到 PHP 5.3.3 以来,我一直在努力寻找一些烦人的会话问题.我已经确定,如果存在活动会话,则从子目录调用 session_start() 会终止现有会话.例如,我启动一个会话,用户登录到 domain.com/index.php,然后用户导航到 domain.com/members/触发 start_session() ......用户的会话丢失.

I've been trying to track down some annoying session issues since my webhost upgrade to PHP 5.3.3 awhile back. I've determined that if there is an active session, calling session_start() from a subdirectory kills the existing session. As an example, I start a session and a user logs in to domain.com/index.php then the user navigates to domain.com/members/ which fires start_session() ... the user's session is lost.

我为此四处寻找,找不到类似的东西.是否有 PHP 配置可以解释这种行为?

I've dug around for this and can't find anything similar. Is there a PHP configuration that would account for this behavior?

推荐答案

如果您的会话在同一目录中正常工作(从您的问题中不清楚),那么这种行为的唯一可能原因,一个非常明显的一:目录"cookie 参数.
除了会话 cookie 参数的默认/"之外,它似乎设置为有些不寻常的值.
你必须检查一下.

if your sessions works all right within the same directory (it is unclear from your question), there is the only possible reason for such a behavior, a pretty obvious one: "directory" cookie parameter.
It seems it is set to somewhat unusual value, other than default "/" for the session cookie parameter.
You have to check it out.

无论如何,在没有HTTP交换日志的情况下尝试任何与会话/cookie相关的问题几乎是无用的.
您必须使用一些 HTTP 嗅探器,例如 LiveHTTPHeaders Firefox 插件,以查看服务器发送的 cookie 标头以及客户端返回的 cookie 标头.
否则一切都会在黑暗中拍摄.

Anyway, it is almost useless to try ANY session/cookie related problem without an HTTP interchange log.
You have to use some HTTP sniffer, like LiveHTTPHeaders Firefox addon to see what cookie header was sent by the server and which one was returned by client.
Otherwise it's all going to be shooting in the dark.

好的,从您的评论看来,会话 ID 保持不变,因此,没有 HTTP 问题可以成为原因.这个问题变得有点棘手.你能在这里发布你的测试脚本吗?

Okay, as it seems from your yonder comment, the session id remains the same, so, no HTTP issue can be a reason. The issue become a kinda tricky to spot. Could you please post your test script here?

这篇关于PHP 5.3.3 - 在子目录中运行 session_start() 会杀死现有会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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