PHP 4.0 Bug #8809 Updated: Cookieless session with Header redirects
| From: | bf at ez dot no | Date: | Tue, 23 Jan 2001 11:33:01 +0000 |
| Subject: | PHP 4.0 Bug #8809 Updated: Cookieless session with Header redirects | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-44802@lists.php.net to get a copy of this message | ||
ID: 8809
User Update by: bf@ez.no
Status: Open
Old-Bug Type: Feature/Change Request
Bug Type: Scripting Engine problem
Description: Cookieless session with Header redirects
When PHP is compiled with --enable-trans-sid http redirects with header() does not work with
cookieless sessions.
This must be a bug.
Here is how I fixed it with php code. The header() function should handle this if --enable-trans-sid
is compiled in:
function ezheader( $string )
{
$sid =& $GLOBALS["PHPSESSID"];
if ( isset( $sid ) )
{
$pos = strpos( $string, "?" );
if ( $pos )
{
$string = $string . "&PHPSESSID=$sid";
}
else
{
$string = $string . "?PHPSESSID=$sid";
}
}
header( $string );
}
This code will automatically append the session id if it exists and that enables cookieless sessions
with header( "Location: " ) redirects.
Previous Comments:
---------------------------------------------------------------------------
[2001-01-19 14:44:53] bf@ez.no
I have code like:
session_start();
if ( !isset( $Foo ) )
{
session_register( "Foo" );
}
else
{
print( $Foo );
}
Header( "Location: /index.php" );
This does not work with cookieless sessions because the session information is not added to the
header() if it's a redirect.
The header() should add the PHPSESSIONID variable to the redirection path if it contains
"Location: " like it does with other URLS and forms.
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=8809