PHPSESSID not being saved to cookie

前端 未结 3 2191
迷失自我
迷失自我 2021-01-05 23:41

the PHPSESSID variable that holds the session id is not being saved into the client cookie. This results in a new session id being generated every time I call the ses

相关标签:
3条回答
  • 2021-01-05 23:46

    It looks like the cookie's domain is being set to localhost. This will only work if you're actually running your website from localhost. You need the session.cookie_domain to match your domain name, optionally with a . in front of it (as in .example.com) to also include subdomains.

    0 讨论(0)
  • 2021-01-05 23:46

    The same thing happened to me, I couldn't log in to my users in Safari and Mac Os browsers, not even Firefox, only on Chrome (pc, not Mac). The reason turned out to be a combination, in php.ini, of

    1. session.cookie_lifetime=0
    2. session.cookie_domain=mydomain

    Where 0 I changed to 3600 (reasonable) as said by Shea and "mydomain" was (all my fault) wrong because it was missing the ".com", the right name of the domain!

    So I ended up changing the config to

    1. session.cookie_lifetime=3600
    2. session.cookie_domain=mydomain.com
    0 讨论(0)
  • 2021-01-06 00:00

    It is not used for Yoav's case, but maybe used for other people who got similar issue:

    don't forget to call session_start()

    It sounds like session_start() would create the PHPSESSID and save it in cookie if it's not sent from client cookie.

    from php.net

    When a visitor accesses your site, PHP will check automatically (if session.auto_start is set to 1) or on your request (explicitly through session_start()) whether a specific session id has been sent with the request. If this is the case, the prior saved environment is recreated.

    some good examples about session_start() http://php.net/manual/en/function.session-start.php

    0 讨论(0)
提交回复
热议问题