Re: understanding session vars ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx
> gregory.machin@xxxxxxxxx
> www.linuxpro.co.za
> www.exponent.co.za
> Web Hosting Solutions
> Scalable Linux Solutions
> www.iberry.info (support and admin)
> 
> +27 72 524 8096

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux