No, you don't need to use HTTP_SESSION_VARS for anything if register_globals is on. Sessions are very simple. You start a session, and you register variables to be part of that session. Like this:
session_start(); session_register('a'); session_register('b'); If you have that at the top of the first page, then whatever values $a and $b have by the time the script finishes is what will be written to the session backend. So, on a subsequent page you just do: session_start(); This will see the session ID that the browser passed to it either via a cookie or in the URL and it will go and restore the variables from the session backend. That means that at this point you can just do: echo $a; echo $b; At no point is there any need for $HTTP_SESSION_VARS nor $_SESSION if you are sure that register_globals will always be on. Now, if you want it to work with register_globals off, you still don't need to use $HTTP_SESSION_VARS when setting the variables, you only need to use it when retrieving them. So, instead of echo $a and echo $b you would have: echo $HTTP_SESSION_VARS['a']; echo $HTTP_SESSION_VARS['b']; Or, of course in newer PHP's you can use $_SESSION['a']. Your stuff probably didn't work because you were setting the session vars via the $HTTP_SESSION_VARS array. That works now, but it probably didn't use to as it is a bit of a weird way to do it. -Rasmus On 12 Aug 2002, Petre Agenbag wrote: > You lost me there... > Are you saying I don't need to access those variable in that way? > Can I simply use $variable in successive pages then? > Surely I MUST use that notation to assign values then right?, specially > to the session vars, right? > > But, just out of curiosity, why does it work fine on my newer system? > > Thanks > > On Mon, 2002-08-12 at 21:17, Rasmus Lerdorf wrote: > > If register_globals is known to be on, why are you worrying about > > the $HTTP_* arrays? > > > > On 12 Aug 2002, Petre Agenbag wrote: > > > > > Hi > > > Me again > > > > > > Still having problems with forms not sending variables, and session > > > variables dissapearing. > > > > > > I have 2 systems, one older 4.0.3 PHP which is my main webserver, so all > > > scripts must comply with it... > > > And the other my development server with the latest 4.1.2 > > > > > > So, I'm trying to write scripts that will happily work on both, and I > > > understand that I must use HTTP_POST_VARS and HTTP_SESSION_VARS in order > > > to comply with 4.0.3. > > > > > > register_globals and track_vars as well as trans_sid are enabled on > > > both. > > > > > > Now, take a look at the example below: > > > index.php > > > > > > <form action="page2.php" method="POST" > > > > <input type="text" name="test"><input type="submit" name="submit"> > > > </form> > > > > > > > > > page2.php > > > > > > <?php > > > session_start(); > > > echo ' HTTP_POST_VARS :'.$HTTP_POST_VARS["test"].'<br>'; > > > echo ' POST_VARS: '.$_POST["test"].'<br>'; > > > echo ' normal test :'.$test.'<br>'; > > > echo 'Session Value (only for > > > re-entry):'.$HTTP_SESSION_VARS["testing"].'<br>'; > > > > > > if ($HTTP_POST_VARS["test"]) { > > > $HTTP_SESSION_VARS["testing"] = $HTTP_POST_VARS["test"]; > > > } > > > echo '<a href="page3.php">Click</a>'; > > > ?> > > > > > > page3.php > > > > > > <?php > > > session_start(); > > > echo 'Session Variable:'.$HTTP_SESSION_VARS["testing"].'<br>'; > > > echo '<a href="page4.php">Forward to test sess var further</a><br>'; > > > echo '<a href="page2.php">Back to test sess var</a><br>'; > > > ?> > > > > > > page4.php > > > > > > <?php > > > session_start(); > > > echo 'Session Variable:'.$HTTP_SESSION_VARS["testing"].'<br>'; > > > echo '<a href="page3.php">Back to page 3 to test sess var > > > further</a><br>'; > > > echo '<a href="page2.php">Back to page 2 to test sess var</a><br>'; > > > ?> > > > > > > This small test works 100% on my newer system, and I was under the > > > impression that I coded it to be backwards compatible with my older > > > system, BUT, > > > > > > look here: http://www.linuxhelp.co.za/session_test to see what it does > > > on my working server. The scripts are identical. > > > > > > Please can you point out my mistakes in reasoning? > > > > > > Also, I want these scripts to work regardless of cookies, so if you see > > > something that might cause problems when ppl disable cookies, plz > > > advise. > > > > > > > > > > > > -- > > > 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