That Caution message is not the full story, read some more on "register_globals".
If register_globals is "On" in php.ini, then do the following: - use session_register() to create your session variables; - use the global variable to access the variable, not the $HTTP_SESSION_VARS array. Example: $myVar = 'test'; session_register('myVar'); $myVar = 'some new value'; print $myVar; Note: the value of $myVar is what is stored to the session at the end of the script. And, since it is stored after the script ends, its value is not available via $HTTP_SESSION_VARS[] until the next page. If register_globals is "Off" in php.ini, then do the following: - do not use session_register(), etc. - use $HTTP_SESSION_VARS for all accesses. Example: $HTTP_SESSION_VARS['myVar'] = 'test'; $HTTP_SESSION_VARS['myVar'] = 'some new value'; print $HTTP_SESSION_VARS['myVar']; Kirk > -----Original Message----- > From: Henry Grech-Cini [mailto:[EMAIL PROTECTED] > Sent: Monday, March 03, 2003 10:29 AM > To: [EMAIL PROTECTED] > Subject: Re: [PHP] Session variable under PHP 4.0.6 > > > Thanks that works in my testing example. But why? The manual says: > > Caution > If you are using $_SESSION (or $HTTP_SESSION_VARS), do not use > session_register(), session_is_registered() and session_unregister(). > > But in index2.php I am using $HTTP_SESSION_VARS and it works?! > > Need a bit of clarification since my actual app still doesn't work! > > Henry > > "Kirk Johnson" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > In the first file, replace this line: > > > > $HTTP_SESSION_VARS['variable']="the variables value"; > > > > with these two lines: > > > > $variable = "the variables value"; > > session_register('variable'); > > > > This is because 'register_globals' is enabled in the php.ini file. > > > > Kirk > > > > > -----Original Message----- > > > From: Henry Grech-Cini [mailto:[EMAIL PROTECTED] > > > Sent: Monday, March 03, 2003 9:34 AM > > > To: [EMAIL PROTECTED] > > > Subject: [PHP] Session variable under PHP 4.0.6 > > > > > > > > > Hi All, > > > > > > I'm having a problem with session variables under PHP 4.0.6 > > > on a secure > > > server. I ran phpinfo and have attached the resulting page > > > after the main > > > body of this message. > > > > > > My test code looks like this > > > > > > Filename: index.php > > > > > > Page Start -------------- > > > > > > <?php > > > session_start(); > > > > > > $HTTP_SESSION_VARS['variable']="the variables value"; > > > > > > ?> > > > <a href="index2.php">click here</a> to go to the next page > > > > > > Page End ------ > > > > > > > > > Next file > > > Filename: index2.php > > > > > > Page Start -------------- > > > > > > <?php > > > session_start(); > > > > > > print_r($HTTP_SESSION_VARS); > > > > > > echo "-->".$HTTP_SESSION_VARS['variable']."<--"; > > > ?> > > > > > > Page End ------ > > > > > > > > > Suffice to say it doesn't work. The first page displays > > > > > > "click here to go to the next page" > > > > > > > > > as expected. However clicking on the link takes you to > > > index2.php and the > > > following is displayed: > > > > > > > > > "Array ( ) --><--" > > > > > > > > > Namely that the session variable called "variable" is not > set in the > > > session. > > > > > > > > > I have run the exact same code on a machine running PHP 4.2.3 > > > (non secure > > > servers) and it works perfectly! And outputs: > > > > > > "Array ( [variable] => the variables value ) -->the variables > > > value<--" > > > > -- > 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