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

From: Date: Fri, 28 Jun 2002 03:07:05 +0000
Subject: Bug #17122 Updated: Values set in _SESSION doesn't stick
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-12299@lists.php.net to get a copy of this message
ID: 17122 Updated by: sniper@php.net Reported By: mats@cdmedia.nu -Status: Open +Status: Bogus Bug Type: Session related Operating System: Linux RH 7.2 PHP Version: 4.2.0 New Comment: Numerical indexes in $_SESSION are NOT supported. (and never will be) User error -> bogus. Previous Comments: ------------------------------------------------------------------------ [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 (#12299) next »