Bug #17122 Updated: Values set in _SESSION doesn't stick

From: Date: Tue, 02 Jul 2002 21:22:19 +0000
Subject: Bug #17122 Updated: Values set in _SESSION doesn't stick
References: 1  Groups: php.bugs php.doc 
Request: Send a blank email to php-bugs+get-12877@lists.php.net to get a copy of this message
ID: 17122 Updated by: eru@php.net Reported By: mats@cdmedia.nu -Status: Open +Status: Verified Bug Type: Documentation problem Operating System: Linux RH 7.2 PHP Version: 4.2.0 Previous Comments: ------------------------------------------------------------------------ [2002-06-28 09:11:18] sniper@php.net You're not supposed to do that. But it should indeed be documented. ------------------------------------------------------------------------ [2002-06-28 06:15:31] mats@cdmedia.nu Ok, that seems reasonable. (Even though I cannot find anything in the manual that explicitly states that numerical indexes are unsupported) However, the setting of a numerical index seems to silently break something, since the other values in the example are affected as well. Is this really the intended behavior? ------------------------------------------------------------------------ [2002-06-27 23:07:05] sniper@php.net Numerical indexes in $_SESSION are NOT supported. (and never will be) User error -> bogus. ------------------------------------------------------------------------ [2002-05-15 08:03:25] Leblanc@somewhere.com what if you try : <? session_start(); session_register("foo"); session_register(4); session_register("a"); session_register("counter"); print "<PRE>"; print "Current values:\n"; print '"foo"=' . $_SESSION["foo"] . "\n"; print '4=' . $_SESSION[4]."\n"; print '"a"=' . $_SESSION["a"]."\n"; $_SESSION["foo"] = "bar"; $_SESSION[4] = "four"; $_SESSION["a"] = "b"; if(!isset($_SESSION["counter"])) $_SESSION["counter"] = 1; else $_SESSION["counter"]++; print "Count = ".$_SESSION["counter"]."\n"; print "</PRE>"; ?> $_SESSION["foo"] and $_SESSION["counter"] should be working $_SESSION[4] doesn't (I guess its because of the numerical key) and $_SESSION["a"] neither (but works if "a" is changed to "ab"). /Leblanc ------------------------------------------------------------------------ [2002-05-09 11:34:40] mats@cdmedia.nu I'm having problems using $_SESSION, it throws away some of my values between page loads. The following code triggers the problem. <? session_start(); print "<PRE>"; print "Current values:\n"; print '"foo"=' . $_SESSION["foo"] . "\n"; print '4=' . $_SESSION[4]."\n"; print '"a"=' . $_SESSION["a"]."\n"; $_SESSION["foo"] = "bar"; $_SESSION[4] = "four"; $_SESSION["a"] = "b"; if(!isset($_SESSION["counter"])) $_SESSION["counter"] = 1; else $_SESSION["counter"]++; print "Count = ".$_SESSION["counter"]."\n"; print "</PRE>"; ?> The first run, it prints this: Current values: "foo"= 4= "a"= Count = 1 Which is what is expected, since the values haven't been set yet, except for the counter. Now the second run, this is where the problem show up: Current values: "foo"=bar 4= "a"= Count = 1 This seems to be wrong! The first value has been set, but none of the others. The counter should have been incremented also. The expected result of the second run would be Current values: "foo"=bar 4=four "a"=b Count = 2 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=17122&edit=1

« previous php.bugs (#12877) next »