#36239 [Opn->Bgs]: $_SESSION Array Assignment Fails
| From: | derick@php.net | Date: | Wed, 01 Feb 2006 08:18:11 +0000 |
| Subject: | #36239 [Opn->Bgs]: $_SESSION Array Assignment Fails | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-92745@lists.php.net to get a copy of this message | ||
ID: 36239
Updated by: derick@php.net
Reported By: martin at itmission dot com
-Status: Open
+Status: Bogus
Bug Type: Session related
Operating System: Windows
PHP Version: 5.1.2
New Comment:
Sorry, but your problem does not imply a bug in PHP itself. For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions. Due to the volume
of reports we can not explain in detail here why your report is not
a bug. The support channels will be able to provide an explanation
for you.
Thank you for your interest in PHP.
This is actually correct behavior. The $_SESSION array is special, and
now you're overwriting it removing its special capabilities.
Previous Comments:
------------------------------------------------------------------------
[2006-02-01 05:37:52] martin at itmission dot com
Description:
------------
$_SESSION does not keep results when assigned an array variable.
Reproduce code:
---------------
test1.php
<?php
session_start();
echo("<a href=\"{$_SERVER['PHP_SELF']}\">click</a>");
print_r($_SESSION);
$_SESSION = array('id' => 1, 'user' => 'test');
session_write_close();
?>
test2.php
<?php
session_start();
echo("<a href=\"{$_SERVER['PHP_SELF']}\">click</a>");
print_r($_SESSION);
$row = array('id' => 1, 'user' => 'test');
$_SESSION = $row;
session_write_close();
?>
test3.php
<?php
session_start();
echo("<a href=\"{$_SERVER['PHP_SELF']}\">click</a>");
print_r($_SESSION);
$row = array('id' => 1, 'user' => 'test');
$_SESSION = $row + array();
session_write_close();
?>
Expected result:
----------------
Test1.php: Works
Test2.php: Fails
Test3.php: Works
Actual result:
--------------
Test1: clickArray ( [id] => 1 [user] => test )
Test2: clickArray ( )
Test3: clickArray ( [id] => 1 [user] => test )
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=36239&edit=1