I think you're missing some fundamental concepts of sessions here. You must think of the session as a file that you're going to include into the script (becuase.. that's litteraly what it is). But instead of using include() you're going to use session_start();
<? session_start(); if (!session_is_registered("myvar")) { $myvar = 'peek a boo'; session_register("myvar"); } else { echo $myvar; session_unregister("myvar"); } echo "<p><a href=\"$PHP_SELF\">(refresh)</a>"; ?> When you activate this script for the first time three things happen.. 1) the session file is created on the server 2) a cookie with the Session ID is stored on your computer 3) $myvar = 'peek a boo'; is added to the session file When you click refresh to reactivate the script, PHP will match the session id stored in the cookie to the file stored on the server, and include the variables into the actively running script. $myvar is now available and the contents are printed to the screen then unregistered (removed) from the session file. The third time around it's going to stop in the if() portion and reregister the variable. Adding and removing lines from a file and including them into your script.. it's no more complicated than that. Hopefully now you'll be able to fix your problem and learn to use sessions reliably and effectively. :) -Kevin ----- Original Message ----- From: "N. Pari Purna Chand" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, July 18, 2002 3:36 PM Subject: [PHP] Refreshing session variables > Hi guys, > > 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 ? > > <? > $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; > > ?> > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php