Re: [Phplib-users] Wierd problems with fallback mode in Session
Brought to you by:
nhruby,
richardarcher
From: Nathaniel P. <np...@te...> - 2003-05-07 17:01:58
|
----- Original Message ----- From: "Kevin Fredrick" <fre...@ip...> To: <php...@li...> Sent: Tuesday, May 06, 2003 4:15 PM Subject: Re: [Phplib-users] Wierd problems with fallback mode inSession > > See: http://www.php.net/manual/en/reserved.variables.php > > > > > This is a 'superglobal', or automatic global, variable. This simply > means > > that it is available in all scopes throughout a script. You don't > need to do > > a global $_SERVER; to access it within functions or methods, as you > do > > with $HTTP_SERVER_VARS. > > > > $HTTP_SERVER_VARS contains the same initial information, but is not > an > > autoglobal. (Note that $HTTP_SERVER_VARS and $_SERVER are different > > variables and that PHP handles them as such) > > > > This might be a bug, or a "global $HTTP_SERVER_VARS" is missing from > the function. Well, it must be a bug, since session.inc always has the "global $HTTP_SERVER_VARS" statement in its functions. In any case, I tested for $HTTP_SERVER_VARS in the global variable space, and it still was empty. I did find, however, that PHP3 (on my server, anyway) registered the SERVER variables as normal global variables, like $HTTP_HOST. So I wrote a little helper function that I call from prepend.php3 to get it working again, and it seems to work as expected. Here it is, for those of you that are curious (this should work for PHP4 as well, if you're having problems there): function import_server_vars() { global $HTTP_SERVER_VARS; $keys = array("QUERY_STRING", "PHP_SELF", "HTTPS", "HTTP_HOST"); while (list(,$key) = each($keys)) { if (!$HTTP_SERVER_VARS[$key]) { #get it from the server autoglobal first if (!$HTTP_SERVER_VARS[$key] = $_SERVER[$key]) { $HTTP_SERVER_VARS[$key] = $GLOBALS[$key]; } } } } _________________________________ Nathaniel Price <np...@te...> Webmaster |