Bug #12859: Session unable to store array of classes

From: Date: Mon, 20 Aug 2001 12:31:20 +0000
Subject: Bug #12859: Session unable to store array of classes
Groups: php.dev 
Request: Send a blank email to php-dev+get-63825@lists.php.net to get a copy of this message
From: philipmateescu@hotmail.com Operating system: W2k, Linux PHP version: 4.0.6 PHP Bug Type: Session related Bug description: Session unable to store array of classes Session is unable to store an array of classes. If you try to add to an array (using []) stored in the session, it overrides the array instead of adding to it Here's a sample code: <? include_once("cls1.php"); if (!session_is_registered("ClassOne")) { session_register("ClassOne"); echo "<BR>ClassOne now in session"; } ?> <BR><B>Right now we have <?= sizeof($HTTP_SESSION_VARS["ClassOne"])?> classes</B>.<P> <? if ($HTTP_GET_VARS["count"] != 0) { for ($i = 0; $i < $HTTP_GET_VARS["count"]; $i++) { $HTTP_SESSION_VARS["ClassOne"][] = new ClassOne(); //this line should add to the array } } ?> <B>And now we have <?= sizeof($HTTP_SESSION_VARS["ClassOne"])?> classes</B>.<P> <form method="get" action="regcls.php"> Register <input type="text" name="count" size="3"> objects. <input type="submit"> </form> <PRE> <? if ($HTTP_GET_VARS["delete"] == 1) { echo "<BR>Killing CountOne from session..."; $HTTP_SESSION_VARS["CountOne"]=0; session_unregister("CountOne"); } for ($i=0; $i < sizeof($HTTP_SESSION_VARS["ClassOne"]); $i++) { echo "\n$i ClassOne->count = ". $HTTP_SESSION_VARS["ClassOne"][$i]->getCount(); } ?> </PRE> <? ?> -- Edit bug report at: http://bugs.php.net/?id=12859&edit=1

« previous php.dev (#63825) next »