PHP session variables lost after redirect

南笙酒味 提交于 2021-01-28 11:27:04

问题


Session variables are lost after using the following code to redirect:

    header('Location: ./protected_page.php');
    exit; //doesn't seem to do anything

On protected page I make sure to use session_start() before referencing any session variables.

Please help!


回答1:


  • You redirect to the same domain.If you are redirecting from www.thedomain.com to thedomain.com can possibly end you session

  • Ensure register_globals is off, you can check this on the php.ini file and also using phpinfo().

  • The session variables aren't overwritten.

  • switching between http and https can also end your session.


来源:https://stackoverflow.com/questions/35237488/php-session-variables-lost-after-redirect

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!