session array :-/

From: Date: Mon, 30 Apr 2001 08:17:08 +0000
Subject: session array :-/
Groups: php.general 
Request: Send a blank email to php-general+get-50829@lists.php.net to get a copy of this message
Hi, I'm having trouble with a two dimensional array with sessions. Following is an example of my code which is split between three pages. -------------------------------- ### myFunctions.php ### function addToMyArray($newStuff) { global $myArray; $myArray[]=array("id"=>$newStuff[myId],"name"=>$newStuff[name]); } ### mainPage.php ### session_start(); include("myFunctions.php"); $myArray=array(); session_register(myArray); // add some stuff to myArray here to highlight the prob $myArray[]=array("id"=>"1","name"=>"gabby"); $myArray[]=array("id"=>"2","name"=>"marla"); .. // if conditions meet addToMyArray($HTTP_POST_VARS); // code to open myOtherWindow.php in a new window. // code to submit a form whos action is PHP_SELF ### myOtherWindow.php ### session_start(); // code to display contents of myArray ------------------------------ Now on first call to addToMyArray() I have three elements two that I added directly and one via the function call. Now if the function gets called again there is still only 3 elements .. two that I added directly and the third one from the latest function call. The element from the first call has simply vanished !!! And that's my problem, why is the element vanishing ??? Thanx, Christian

« previous php.general (#50829) next »