> -----Original Message----- > From: Johnson, Kirk [mailto:[EMAIL PROTECTED] > Sent: 19 June 2003 20:31 > To: [EMAIL PROTECTED] > Subject: [PHP] Migrating pre-4.1 code to a post-4.1 server with > register_globals on > > > A heads-up to those who are moving old code with > register_globals "on" to a > server with a newer PHP version and register_globals still "on": > > In the old days, the rule was simple. For a session variable, > whatever value > was in the global variable at the end of the script was what > was saved to > the session, and that value was restored on the next page. > > Under a newer version of PHP, e.g., 4.3.2, this is no longer > true in one > case. Assume we have a session variable, 'a', that has been > assigned some > value: > > $a = 'someValue'; > session_register('a'); > > Then > > unset($a); > > will unset the global variable, $a, but NOT the corresponding > element in the > two session arrays, $HTTP_SESSION_VARS and $_SESSION.
Actually, this should only be true for versions 4.1.0 to 4.2.3 -- the manual page at http://uk.php.net/manual/en/ref.session.php (admittedly a *long* way down it and hidden under the "Examples" heading!) contains this warning: "There is a defect in PHP 4.2.3 and earlier. If you register a new session variable by using session_register(), the entry in the global scope and the $_SESSION entry will not reference the same value until the next session_start(). I.e. a modification to the newly registered global variable will not be reflected by the $_SESSION entry. This has been corrected in PHP 4.3." Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: [EMAIL PROTECTED] Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php