ID:               24270
 Updated by:       [EMAIL PROTECTED]
-Summary:          unset($var) doesn't unset session value with
                   register_globals on
 Reported By:      kjohnson at zootweb dot com
-Status:           Open
+Status:           Bogus
 Bug Type:         Session related
-Operating System: Linux
+Operating System: Solaris 8 & 9
 PHP Version:      4.3.2
 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

This is expected behavior though. session_register only makes a
reference to the global variable. When you unset it, the session still
holds the 2nd reference to the data, and thus is it still set.


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

[2003-06-20 11:53:03] kjohnson at zootweb dot com

Description:
------------
This is related to bug #19586 and only applies when register_globals is
"on". If a global variable is registered to the session, then an
unset() on that global variable will unset it on the current page, but
its original value is restored on the next session_start(). I expected
it to also be unset in the session, which is how it behaved in older
versions of PHP. The workaround provided in bug #19586, unset($var,
$_SESSION['var']), does work. However, this means that older code
written for register_globals "on" may behave differently when moved to
newer PHP versions, a subtle bug. It would be helpful if the code was
fixed or the documentation updated to make folks aware of this
potential problem.

Reproduce code:
---------------
file: test.php
<?
session_start();
$a = 'zero';
session_register('a');
unset($a);
?>
<br><a href='./test2.php'>next</a>

file: test2.php
<?
session_start();
echo "a is $a<br>";
?>

Expected result:
----------------
I expected $a to not have a value on test2.php, which is the case for
this same code running on PHP 4.0.6.

Actual result:
--------------
On the second page, test2.php, $a has the value 'zero', as originally
assigned on the first page.


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


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

Reply via email to