#32564 [Com]: unset session in foreach

From: Date: Mon, 04 Apr 2005 10:43:11 +0000
Subject: #32564 [Com]: unset session in foreach
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-76292@lists.php.net to get a copy of this message
ID: 32564 Comment by: duh at dowebwedo dot com Reported By: echenavaz at mengine dot fr Status: Feedback Bug Type: Session related Operating System: debian 2.6.9 PHP Version: 5.0.4 New Comment: I did not experience any problems with Apache/1.3.29 (Unix) PHP/5.0.4 on Debian stable. Code: <?php $_SESSION['one'] = 1; $_SESSION['two'] = 2; $_SESSION['three'] = 3; print_r($_SESSION); foreach ($_SESSION as $key_session => $session) unset($_SESSION[$key_session]); print_r($_SESSION); ?> Result is as expected: Array ( [DF_debug] => 1 [one] => 1 [two] => 2 [three] => 3 ) Array ( ) Previous Comments: ------------------------------------------------------------------------ [2005-04-04 10:23:51] tony2001@php.net Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If possible, make the script source available online and provide an URL to it here. Try to avoid embedding huge scripts into the report. ------------------------------------------------------------------------ [2005-04-04 10:17:18] echenavaz at mengine dot fr Description: ------------ work fine whith 5.0.0 do not work whith 5.0.4 (whith zlib.output_compression = On) Reproduce code: --------------- foreach($_SESSION as $key_session => $session) { if(substr($key_session, 0, 17) == "session_pm_search") { unset($_SESSION[$key_session]); } } $forward_url = "https://".$_SERVER['HTTP_HOST'].$_SERVER['SCRIPT_NAME']; header("location:$forward_url"); die(); Expected result: ---------------- $_SESSION['session_pm_searchXXXXX'] are unset Actual result: -------------- $_SESSION['session_pm_searchXXXXX'] are not unset ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=32564&edit=1

« previous php.bugs (#76292) next »