In PHP 4.1.0 or greater, all you need to use sessions is this:
<?php session_start(); // this tells the script to either create a session // or to use a current session if the script has been // passed a session ID via a cookie or GET request $_SESSION['var1'] = $varablename; // this tells the script to take the value of the // "variablename" variable and assign that to the // "var1" variable, which is a session variable. $_SESSION['var1'] = $_POST['var1']; // this tells the script that the user-supplied value // contained by the "var1" variable from a POST request // (usually from a HTML form) should now be contained by // a session variable called "var1". echo $_SESSION['var1']; // this does exactly what you think it does, and of course // this variable can be manipulated in other ways. echo() // is just an easy example. Since the $_* variables are always global (hence the name "superglobals"), you never need to worry about the scope of these variables. And you never need to use session_register() again. All of the above code is register_globals=off-compliant. Erik On Thursday, March 14, 2002, at 04:36 PM, Donna Dufort wrote: > I'm attempting to understand how to use session variables with > register_globals off. Listed below are three very simple pages that > pass > session variables. > > ====>>>With register_globals off: > I'm only able to see $ses_var1 if I refer to it with > $HTTP_SESSION_VARS['ses_var1'] or > $_SESSION['ses_var1'] and not by using $ses_var1. This only works if I > used > session_register('ses_var1') then set it using > $ses_var1 = "something";. Per everything I've been reading I expected > it > to work more like how I have ses_var2 setup but ses_var2 only produces > output on page1.php > > Also I didn't expect $HTTP_SESSION_VARS['ses_var1'] to return anything > since > I did not declare them as global in page2 or page3. > > > ====>>>With register_globals on: > Same results as above except $ses_var1 does produces output on any page > that > asks. > > > Am I doing something wrong? > > Using Windows 2k/IIS, we are also using Linux and Apache but we haven't > upgraded that machine yet. > > ================= > page1.php > ================= > session_start(); > session_register('ses_var1'); > > $ses_var1 = "Hello World"; > > $_SESSION['ses_var2'] = "huh?"; > > echo "\$ses_var1 is ".$ses_var1; > echo "<br>"; > > echo "\$_SESSION['ses var2'] is ".$_SESSION['ses_var2']; > echo "<br>"; > > ?> > <center> > <br><br><br><br><br> > <form method=post action="page2.php"> > <table bgcolor=#cccccc> > <tr> > <td>Username:</td> > <td><input type=text name=username></td></tr> > <tr> > <td><input type=submit value="submit"></td></tr> > </table></form> > </center> > > ================= > page2.php > ================= > session_start(); > echo "\$HTTP_SESSION_VARS['ses_var1'] is > ".$HTTP_SESSION_VARS['ses_var1']; > echo "<br>"; > > echo "\$_SESSION['ses_var1'] is ".$_SESSION['ses_var1']; > echo "<br>"; > > echo "\$ses_var1 is ".$ses_var1; > echo "<br>"; > > echo "<br>"; > echo "<hr>"; > > echo "\$HTTP_SESSION_VARS['ses_var2'] is > ".$HTTP_SESSION_VARS['ses_var2']; > echo "<br>"; > > echo "\$_SESSION['ses var2'] is ".$_SESSION['ses_var2']; > echo "<br>"; > echo "\$ses_var2 is ".$ses_var2; > echo "<br>"; > > echo "<br>"; > echo "<hr>"; > echo "post var name is: ".$_POST['username']; > echo "<br>"; > > ?> > <a href = "page3.php">Next page</a> > > > ================= > page2.php > ================= > session_start(); > > echo "\$HTTP_SESSION_VARS['ses_var1'] is > ".$HTTP_SESSION_VARS['ses_var1']; > echo "<br>"; > > echo "\$_SESSION['ses_var1'] is ".$_SESSION['ses_var1']; > echo "<br>"; > > echo "\$ses_var1 is ".$ses_var1; > echo "<br>"; > > echo "<br>"; > echo "<br>"; > > echo "\$HTTP_SESSION_VARS['ses_var2'] is > ".$HTTP_SESSION_VARS['ses_var2']; > echo "<br>"; > > echo "\$_SESSION['ses var2'] is ".$_SESSION['ses_var2']; > echo "<br>"; > > ?> > <a href = "page1.php">Return to Page 1</a> > > > > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > - - > - - - - - - - - - - - - - - - - - - - - - - - - > Please Note: The information contained in this message may be privileged > and > confidential and protected from disclosure. If the reader of this > message > is not the intended recipient, you are hereby notified that any > dissemination, distribution or copying of this message is strictly > prohibited. If you have received this in error, please notify us > immediately > by replying to the message and deleting it from your computer. > > Thank you - Tobin & Associates, Inc. > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - > - - > - - - - - - - - - - - - - - - - - - - - - - - - > > > ---- Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php