RE: [PHP] Migrating pre-4.1 code to a post-4.1 server with regist er_globals on
| From: | Ford, Mike [LSS] | Date: | Fri, 20 Jun 2003 08:57:08 +0000 |
| Subject: | RE: [PHP] Migrating pre-4.1 code to a post-4.1 server with regist er_globals on | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-152287@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Johnson, Kirk [mailto:kjohnson@zootweb.com]
> Sent: 19 June 2003 20:31
> To: php-general@lists.php.net
> 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: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211