PHP session losing data between pages

后端 未结 2 1185
梦谈多话
梦谈多话 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

提交回复
热议问题