Reputation: 2820
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
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
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:
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
Upvotes: 2