#14636 [Com]: Session variables are lost when redirecting to a url using header() function.
| From: | moon_wizard at yahoo dot coom | Date: | Fri, 23 Jan 2004 06:53:12 +0000 |
| Subject: | #14636 [Com]: Session variables are lost when redirecting to a url using header() function. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-53788@lists.php.net to get a copy of this message | ||
ID: 14636
Comment by: moon_wizard at yahoo dot coom
Reported By: kannan at tmsassociates dot com
Status: Bogus
Bug Type: Session related
Operating System: windows 2000 professional
PHP Version: 4.0.6
New Comment:
I just ran into the same issue. I set up PHP and Apache on my home
Windows machine. I was able to successfully set SESSION variables and
recover after a header() call.
When I moved the file to my hosting provider, the SESSION variables
were lost. I think that my hosting provider might be using IIS.
I tried the session_write_close() with no success.
John Gregory
Previous Comments:
------------------------------------------------------------------------
[2004-01-13 15:34:34] mgandalf at seznam dot cz
Hi, I just look at your source and php.ini and it was clear
to me. Problem is here: "session.cookie_path = c:\temp".
It is not path to file but path on web server where is
cookie valid. So change it to "session.cookie_path = /"
and it will work. When it is for example "/dir_name",
cookie is valid just for http://server/dir_name/, but not
for http://server/dir_name2/ and in this 2nd case will not be
sent.
Gandalf
------------------------------------------------------------------------
[2004-01-09 17:47:15] writeto_ben at hotmail dot com
I would have liked a simple header redirect as well, but unfortunately
the other suggestions didn't solve the issue. However, setting a
javascript redirect seemed to do the trick. I'm using Win2k
professional, IIS 5.0, PHP Version 4.3.4
This will work on IE browsers. Just modify the javascript for netscape
compatibility.
<?
//...perform login check, produce $errStr if fails
if($errStr){
header("Location: login.php?err=".$errStr);
}else{
print '<html>
<body
onload=eval("window.location.href=\'http://blahblahblah/default.php\';");></body>
</html>';
}
?>
------------------------------------------------------------------------
[2003-12-05 23:28:10] venki_cute123 at rediffmail dot com
i have a session variable to be accessed in same page but submit twice
in same page at third time I am not able to access session variable
------------------------------------------------------------------------
[2003-11-22 18:18:19] andrew dot whale at which dot net
Hi
I've also had a similar problem of session variables not being passed
following a call to header(). I am running PHP 4.0.15 on an XP m/c.
The following worked for me, by placing a session_write_close() before
the call to header, followed by and exit():
session_write_close();
header("Location: $strPage");
exit();
I hope this will be of use to some.
Andrew Whale
------------------------------------------------------------------------
[2002-02-07 21:23:36] yohgaki@php.net
This issue will not be able to be fixed by PHP.
Some browser does not set cookie for initial request.
To make sure cookie is enabled _always_, user must check it first.
http://www.zend.com/search_code_author.php?author=yohgaki
Use session helper html or other people post without JavaScript
version.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/14636
--
Edit this bug report at http://bugs.php.net/?id=14636&edit=1