ID:               32886
 User updated by:  luis at infomed dot sld dot cu
 Reported By:      luis at infomed dot sld dot cu
-Status:           Bogus
+Status:           Open
 Bug Type:         Session related
 Operating System: *
 PHP Version:      5.0.4
 New Comment:

Please, maybe, I dont explain the problem very well, I try to overwrite
the session array but dont work, look at the page2:
$buffer['varA'] = $_SESSION['varA'];
$_SESSION = array();//here I clear the session,become empty
$_SESSION = $buffer;//assign a new array,cause array $buffer
print_r($_SESSION);
//on screen the right result,
//but on the session file is wrong.

So, I want to overwrite the session variable with a new array but php
dont do it, then, the onscreen result between page2 and page3 are
different and it is not correct because in both pages I have the same
statement: print_r($_SESSION); with different results.
Please, if you can, read carefully my tests.
Best regards,
Luis


Previous Comments:
------------------------------------------------------------------------

[2005-04-29 09:08:10] [EMAIL PROTECTED]

Not a bug. If you overwrite the $_SESSION array by assigning a new
array to it, you remove it's magic properties of being the array with
session variables. This is expected - so don't do it.

------------------------------------------------------------------------

[2005-04-29 08:45:16] luis at infomed dot sld dot cu

Description:
------------
php5.0.4 dont store the correct values after modified the $_SESSION
variable, the idea is to clear the session and do persist only a few
values. I use Apache 1.3.33. With php5.0.2 everything is fine the
problem appear with php5.0.4, I am not try with php5.0.3


Reproduce code:
---------------
page1.php-----------------------------------------

<?php
session_start();
$_SESSION['varA'] = 'aaa';
$_SESSION['varB'] = 'bbb';
?>

page2.php-----------------------------------------

<?php
session_start();
$buffer['varA'] = $_SESSION['varA'];
$_SESSION = array();
$_SESSION = $buffer;
print_r($_SESSION);
?>

page2b.php-----------------------------------------

<?php
session_start();
$_SESSION = array();
$_SESSION['varA'] = 'aaa';
print_r($_SESSION);
?>

page3.php-----------------------------------------

<?php
session_start();
print_r($_SESSION);
?>


Expected result:
----------------
I would expect the same behavior with:
page1.php->page2.php->page3.php
and with:
page1.php->page2b.php->page3.php
but is not.


Actual result:
--------------
When I do page1.php->page2.php on the screen I obtain the correct
values:
Array ( [varA] => aaa )
but on the session file in disc is wrong, because the session file
have:
varA|s:3:"aaa";varB|s:3:"bbb";
and in page3.php on the screen I have:
Array ( [varA] => aaa [varB] => bbb ), is wrong.

But, if I do page1.php->page2b.php->page3.php everything is fine.

Thank you for your work in PHP.



------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=32886&edit=1

Reply via email to