Re: sessions not working when page redirects
| From: | John W. Holmes | Date: | Tue, 10 Aug 2004 12:45:57 +0000 |
| Subject: | Re: sessions not working when page redirects | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-193266@lists.php.net to get a copy of this message | ||
From: "Angelo Zanetti" <binc2@ctech.ac.za>
> Im having a slightly weird problem with my session variables. when on a
> certain page call it "A", I register a session variable and assign it a
> value. I then test if it is registered successfully and has the correct
> value on the same page, that works no problem. After that page "A"
> redirects to page "B":
>
> header("Location: ../admin/include/B.php");
This should be a complete URL to begin with:
http://www.yourdomain.com/whatever/admin/include/B.php
> After this I do the exact same test on page "B" to test for successful
> registration and value and I get that the session variable is not
> registered. on page "B" I do have session_start(); at the top. I even do
> 2 tests to on the session variable:
Using IE?
Try using session_write_close() right before you redirect with the header()
and be sure to put exit() directly after header(). Should look like this
anytime you want to redirect.
session_write_close();
header(...);
exit();
If that doesn't work, then pass the session ID in the URL when you redirect
like someone else mentioned.
---John Holmes...