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. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -