问题
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