Page 1 of 1

Why exit doesn't reset the Session.

Posted: Tue Dec 21, 2010 7:31 am
by Redorc
Hi, I have a problem with a redirection. I want to redirect with the header function(), but if i use this function my $_SESSION is resetted.
Code:
header('Location: index.php' );

I have found a solution, if i write exit () after the header() my $_SESSION isn't resetted.
Does anyone know why?
Thanks :D

Re: Why exit doesn't reset the Session.

Posted: Tue Dec 21, 2010 7:44 am
by Darhazer
If you do not put exit; after the redirect, the rest of the code will be executed.
Browser also can bypass the redirect header, so the user can see the page.

Most likely there is some code after the header() function that resets the session (but terminating the execution with exit; does not allow it to be executed)

Re: Why exit doesn't reset the Session.

Posted: Tue Dec 21, 2010 7:58 am
by Redorc
If you do not put exit; after the redirect, the rest of the code will be executed.
I didn't know this 8O I don't like it but i can handle :)
Thanks a lot for the help :D :drunk: