Re: Refreshing session variables

From: Date: Fri, 19 Jul 2002 02:21:39 +0000
Subject: Re: Refreshing session variables
Groups: php.general 
Request: Send a blank email to php-general+get-108410@lists.php.net to get a copy of this message
>I got a problem with refreshing session variables. >When the following code is run , for the first time >both $z and $secretstring are showing same values. > >But when page is refreshed, the $secretstring variable >is still having the old value no matter how many times >I click refresh. > >Am I missing some thing ? I always put the session_register stuff *before* I start putting stuff into my variables, but maybe that's just me... What you are missing, though is that whether you 'unregister' it or not, you *always* 'register' it again in the next line. If you expect it to change, you'd need: else{ session_regsiter('secretstring'); } ><? >$x = mt_rand (1000,10000); >$y = mt_rand (1000,10000); > >$text = $x.$y; >$secretstring =$x.$y; > >session_start(); >if(session_is_registered("secretstring")){ >session_unregister("secretstring"); >} >session_register("secretstring"); > >echo "<BR>".$text; >echo "<BR>".$secretstring; > >?> > -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#108410) next »