Re: understanding session vars ?

From: Date: Thu, 24 Nov 2005 08:55:36 +0000
Subject: Re: understanding session vars ?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-226401@lists.php.net to get a copy of this message
Gregory, Are you always setting $_SESSION['menu'] to the contents of $_GET['menu']? If so, the second link will set $_SESSION['menu'] to null. You need to check the contents of $_GET['menu'] first before setting, i.e. if (isset($_GET['menu'])) $_SESSION['menu'] = $_GET['menu']; Cheers, David Grant Gregory Machin wrote: > Hi > I'm a bit stuck on session var, and thier implamentation, or my perseption > thier of. > I have a page and need certian vars to be persistat each time the page is > called. > This is done to detmin the content of the page through logic that calls > different includes. > > But I cant get the vars to be persistant. > note the page call it's self. > > ./index.php > <?php > session_start(); > $_SESSION['menu'] > > ?> > <html><A href=./index.php?menu=1>option 1</A></html> // this works > <html><A href=./index.php?other=do>differnt action</A></html> // this > brakes > it . when the user links here the 'menu' var is cleared > <?php $_SESSION['menu'] = $_GET['menu']; > echo $_SESSION['menu']; > > ?> > > I would like the menu var (and others) to be persistant until it is reset or > updated. how do I acheave this . > > Thanks > > > > > > > -- > Gregory Machin > greg@linuxpro.co.za > gregory.machin@gmail.com > www.linuxpro.co.za > www.exponent.co.za > Web Hosting Solutions > Scalable Linux Solutions > www.iberry.info (support and admin) > > +27 72 524 8096

« previous php.general (#226401) next »