|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-12-24 19:00 UTC] niklas-phpbugs at alberth dot com
I got an array as a session var, then on one page I do
unset($basket);
$basket = array();
session_register("basket");
to empty the array but the array seems to be unaffected.
The exact same code works on 4.0.5.
4.1.0 setup:
'./configure' '--with-apxs=/usr/local/apache/bin/apxs' '--disable-debug' '--enable-track-vars' '--with-pgsql' '--with-gd=../gd-1.8.4' '--with-zlib=/usr' '--with-jpeg-dir=/usr' '--with-ttf' '--with-xslt' '--with-xslt-sablot'
--niklas
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 19:00:02 2025 UTC |
Using 4.2.0.RC2 this behavior still there, you can check with these scripts: ## i2.php <?php session_start(); $counter = 1; session_register("counter"); header("Location: /i.php"); ?> ## i.php <?php session_start(); $counter = 0; ### uncomment this to see the difference # session_unregister("counter"); session_register("counter"); unset($counter); $counter = 4; session_register("counter"); header("Location: /i1.php"); ?> ## i1.php <?php session_start(); print $counter; ?> And then open http://host/i2.php in browser window. Expected output - 4, but I get 0.With register_globals = off I get nothing, i.e. no number, just newline, with or without session_unregister("counter"). Seems like $counter does not exist at all.I see you miss the point. I have made that example of three scripts with redirects to easy things. You can equaly put links into scripts and then click them manualy with the same effect. All Set_Cookie and Redirect headers look fine. Take a look at the first message here from niklas-phpbugs@alberth.com. I can only speculate why this does not work in 4.1 or 4.2: when you register variable with session_register php it puts a referense to variable. When unset function unsets variable, session variable still hold reference to old variable, though it does not exist anymore. When you try to reregister variable with session_register it thinks that that variable already registered, and does nothing. So whaterver new value you assign id does not reach session module, even at exit of the script. But in theory session should reference to the name of variable not variable itself, and if variable is gone in context so must session registered one. And if you use session_unregister in the same script as unset, you would get correct result. (see ### uncomment this to see the difference # session_unregister("counter");). I don't want to insult anyone but I am amazed that such simple bug have not been fixed several monthts yet.