ID: 36646
User updated by: christian dot cal at gmx dot de
Reported By: christian dot cal at gmx dot de
Status: Open
Bug Type: Session related
Operating System: Windows XP
PHP Version: 5.1.2
New Comment:
I recently figured out that apache crashed when running into an
infinitive loop it ran by using header("Location: "), because the vars
in $_SESSION wasn't unset by unset().
I believe the error with not unsetting vars in foreach() has been
posted.
Previous Comments:
------------------------------------------------------------------------
[2006-03-07 15:04:48] christian dot cal at gmx dot de
Description:
------------
I am using PHP as an apache2 modul.
When trying to unset all vars that are stored in $_SESSION i use a
foreach loop combined with unset. This method crashes the apache2.
I moved from PHP 4.4.2 to 5.1.2. The unmodified code works for 4.4.2
but crashes the server when using 5.1.2.
Reproduce code:
---------------
foreach ($_SESSION as $key => $value){
unset($_SESSION[$key]);
}
Expected result:
----------------
All vars should be removed from $_SESSION
So i tried this:
$helper=&$_SESSION;
foreach ($helper as $key => $value){
unset($helper[$key]);
}
This code does what I have expected from the code above.
Also this works:
$helper=array_keys($_SESSION);
foreach ($helper as $key){
unset($_SESSION[$key]);
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=36646&edit=1