简体   繁体   English

通过https的cookie中的phpsessid

[英]phpsessid in cookie over https

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. 在我的本地WAMP服务器中,当我调用session_start() ,将在cookie中设置会话ID如下,而var_dump($_COOKIE)给出以下内容。

array
  'PHPSESSID' => string 'qg8nrlpdtgb391386lhghgv727' (length=26)

so when I call session_start() again, my previous session is resumed. 因此,当我再次调用session_start()时,我的上一个会话将恢复。

but when I deployed the same code to my web-server, the PHPSESSID is not being set in the cookie. 但是当我将相同的代码部署到Web服务器时,未在cookie中设置PHPSESSID。 So as a result, every time I call session_start(), a new session is getting created instead of resume the previous session. 因此,每次我调用session_start(),都会创建一个新会话,而不是继续上一个会话。

Can anyone please tell me a possible cause of the problem. 谁能告诉我这个问题的可能原因。 Do we have to explicitly set the PHPSESSID to the cookie? 我们是否必须将PHPSESSID显式设置为cookie?

Also, In my local(WAMP) I dont have https, but the web-server where I pushed the code is https. 另外,在我的本地(WAMP)中,我没有 https,但是我推送代码的Web服务器是https。 Is this a problem? 这有问题吗?

I am stuck with this for almost 3 days now. 我已经坚持了将近3天。

Thanks in advance. 提前致谢。 Kanna 卡纳

Looks like session handling is configured differently on this webserver. 看起来会话处理在此Web服务器上的配置有所不同。 You should compare the values set in the php.ini file under the session-section. 您应该在会话部分下比较php.ini文件中设置的值。

Especially: 特别:

  1. Is session.use_cookies set to 1? session.use_cookies是否设置为1?
  2. Does session.save_path point to a valid directory, where the webserver user has write permission session.save_path是否指向Web服务器用户具有写许可权的有效目录

See here for a full list of session-settings: http://de3.php.net/manual/de/session.configuration.php 有关会话设置的完整列表,请参见此处: http : //de3.php.net/manual/de/session.configuration.php

I had called session_start() immediately after html < head > tag. 我在html <head>标记后立即调用了session_start()。 This was the problem. 这就是问题所在。 When I moved the session_start() method before the html head tag, the problem was solved. 当我将session_start()方法移到html head标记之前时,此问题已解决。

Thanks everyone for your help. 感谢大家的帮助。
Kanna 卡纳

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

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