https 上的 cookie 中的 phpsessid
在我的本地 WAMP 服务器中,当我调用 session_start()
时,会话 ID 将在 cookie 中设置如下,并且 var_dump($_COOKIE)
给出以下内容。
array
'PHPSESSID' => string 'qg8nrlpdtgb391386lhghgv727' (length=26)
因此,当我再次调用 session_start() 时,我之前的会话将恢复。
但是当我将相同的代码部署到我的网络服务器时,PHPSESSID 没有在 cookie 中设置。因此,每次我调用 session_start(),
都会创建一个新会话,而不是恢复上一个会话。
谁能告诉我问题的可能原因。 我们是否必须显式地将 PHPSESSID 设置为 cookie?
另外,在我的本地(WAMP)中,我没有有 https,但是我推送的 Web 服务器代码是https。这是一个问题吗?
我已经被这个问题困扰了近 3 天。
提前致谢。 神无
in my local WAMP server, when I call session_start()
the session-id is being set in the cookie as follows and var_dump($_COOKIE)
gives the following.
array
'PHPSESSID' => string 'qg8nrlpdtgb391386lhghgv727' (length=26)
so when I call session_start() again, my previous session is resumed.
but when I deployed the same code to my web-server, the PHPSESSID is not being set in the cookie. So as a result, every time I call session_start(),
a new session is getting created instead of resume the previous session.
Can anyone please tell me a possible cause of the problem. Do we have to explicitly set the PHPSESSID to the cookie?
Also, In my local(WAMP) I dont have https, but the web-server where I pushed the code is https. Is this a problem?
I am stuck with this for almost 3 days now.
Thanks in advance.
Kanna
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来此网络服务器上的会话处理配置不同。您应该比较会话部分下 php.ini 文件中设置的值。
特别是:
session.save_path
是否指向一个有效的目录,其中网络服务器用户具有写入权限请参阅此处以获取会话设置的完整列表:
http://de3.php.net/manual/de/session.configuration.php
Looks like session handling is configured differently on this webserver. You should compare the values set in the php.ini file under the session-section.
Especially:
session.use_cookies
set to 1?session.save_path
point to a valid directory, where the webserver user has write permissionSee here for a full list of session-settings:
http://de3.php.net/manual/de/session.configuration.php
我在 html < 之后立即调用了 session_start()头>标签。这就是问题所在。当我将 session_start() 方法移到 html head 标记之前时,问题就解决了。
感谢大家的帮助。
神无
I had called session_start() immediately after html < head > tag. This was the problem. When I moved the session_start() method before the html head tag, the problem was solved.
Thanks everyone for your help.
Kanna