PHP session losing data between pages

后端 未结 2 1164
梦谈多话
梦谈多话 2021-01-03 01:28

I am trying to set up a login system for my website that requires someone to be logged in in order to post. I have set it up with sessions and it works great on my localhos

相关标签:
2条回答
  • 2021-01-03 01:38

    The only time I´ve had a similar problem, was when I was accidentally changing the domain while going to another page (from www.mydomain.com tomydomain.com and the other way around).

    You can have your session persist between different sub-domains using session_set_cookie_params():

    session_name('login_session');
    session_set_cookie_params(0, '/', '.mydomain.com');
    session_start();
    

    Edit: Perhaps this can help you: A very interesting article: PHP Session Debugging

    0 讨论(0)
  • 2021-01-03 01:40

    I found the problem - the save directory for the PHP sessions was a root apache directory, and I'm runnin nginx fastcgi. I just changed the root permissions for the folder and it works. Thanks a ton for all of your help.

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