PHP $-SESSION variables disappear on new page and return empty

后端 未结 1 544
無奈伤痛
無奈伤痛 2020-12-22 01:09

I\'m having an issue with the Sessions Variables. Ever since i switched from mysqli to PDO. It worked fine with mysqli, but ever since i switched to PDO, this issue has now

相关标签:
1条回答
  • 2020-12-22 01:22

    Are you using http or https to access your local site? If you are using secure cookies PHP won't read them under http instead it starts a new session with a new cookie, switching to https solves this problem.

    It looks from your sec_session function that you are using secure cookies ($secure = SECURE;) so is your browser session using HTTPS? If you are using HTTP with secure cookies you will start a new session on each page and won't have access to existing session variables.

    The best solution is to access your local site with https just like you would for your live site but if you switch off the secure cookie setting for your local site that will work too.

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