ID: 39193 Comment by: john dot cecere at sun dot com Reported By: gearb0x at eml dot cc Status: Assigned Bug Type: Session related Operating System: Linux FC4 PHP Version: 5.1.6 Assigned To: iliaa New Comment:
I ran into this today with PHP 5.1.6. I spent most of the afternoon trying to figure out why my vars were coming back after a header() call. One might suggest that this isn't a bug and that this behavior is described in the docs (the session_unregister page for example). I would disagree with this. This behavior is very quirky and completely counter-intuitive. It would be much better for unset to behave in a way that you would expect, i.e. to unset a variable (or element of a variable) so that it stays unset, regardless of whether that variable happens to be $_SESSION or not. John Previous Comments: ------------------------------------------------------------------------ [2006-10-19 15:40:04] gearb0x at eml dot cc It doesnt clear it, all variables stay intact as they were when the session started. It clears it in the current execution of the script, but the next time the page loads all the variables are back as they were before they were unset call If i make any changes to session variables AFTER ive tried to unset one they are not saved in the session on the next page load Its as if the session doesnt save, even forcing the save with session_write_close does not work ------------------------------------------------------------------------ [2006-10-19 07:47:04] [EMAIL PROTECTED] 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 the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. >This should clear the session. But it does ... instead? ------------------------------------------------------------------------ [2006-10-19 04:19:11] gearb0x at eml dot cc replacing unset($_SESSION[$key]) with session_unregister($key) has the desired effect -- which your not suposed to use according to all docs. ------------------------------------------------------------------------ [2006-10-19 04:01:21] gearb0x at eml dot cc Description: ------------ For some reason unseting session variables is stopping php from saving any session variables. The code below should clear the session but it isnt, this code worked fine on 5.1.2 on a freeBSD box. Also ive noticed that if i make any changes to the session variables (ie: adding new ones) they dont get saved in the session either Reproduce code: --------------- <?php session_start(); foreach($_SESSION as $key=>$value) { unset($_SESSION[$key]); } ?> Expected result: ---------------- This should clear the session. Also, any other changes made to the session arent saved either (ie: creating more session variables ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=39193&edit=1