kanap008
kanap008

Reputation: 2820

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.

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

Upvotes: 1

Views: 3439

Answers (2)

kanap008
kanap008

Reputation: 2820

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

Upvotes: 1

JochenJung
JochenJung

Reputation: 7213

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:

  1. Is session.use_cookies set to 1?
  2. Does session.save_path point to a valid directory, where the webserver user has write permission

See here for a full list of session-settings: http://de3.php.net/manual/de/session.configuration.php

Upvotes: 2

Related Questions