Re: sessions nightmare

From: Date: Wed, 11 Sep 2002 09:00:54 +0000
Subject: Re: sessions nightmare
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-115945@lists.php.net to get a copy of this message
> I want to be able to have a user login (which is completed), they > goto a search page (completed), and search for a particular item > (completed). A page will display all the links for the items searched > for (completed). What I want out of sessions is to when they click on > the link for a particular item, the item number stay in a session so > it can be called through out each page they goto. What I have as a > base of test code is the following (this was taken from someone's > example): > > test1.php: > > <?php > session_start( ); > session_register("SESSION"); > > *** THE FOLLOWING VARIABLE ($retrived_itemno) WOULD NEED TO BE SET ON > THE *** SEARCH PAGE *** > $SESSION["item"] = $retrived_itemno; > test2.php: > > <?php > session_start( ); > echo "the retrived value equals: $SESSION[item]"; > ?> In test2.php: Your echo line is incorrect. $SESSION[item] is not defined, $SESSION["item"] probably is...but why are you storing an array in a session? Try using $_SESSION instead of session_register, e.g.: test1.php: $SESSION["item"] = $retrieved_itemno; $_SESSION["SESSION"] = $SESSION; test2.php: $SESSION= $_SESSION["SESSION"]; echo "The retrieved value equals to " . $SESSION["item"]; HTH Erwin

« previous php.general (#115945) next »