> -----Original Message-----
> From: Ford, Mike [LSS] [mailto:[EMAIL PROTECTED]
> Sent: Friday, June 20, 2003 2:57 AM
> To: Johnson, Kirk; [EMAIL PROTECTED]
> Subject: RE: [PHP] Migrating pre-4.1 code to a post-4.1 server with
> regist er_globals on
> 
> 
> > -----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."

Please let me clarify what I am saying. The manual reference above is
correct, *to a point*.

In 4.3.2, when you *assign* to any one of the session variable $a,
$HTTP_SESSION_VARS['a'], or $_SESSION['a'], you simultaneously *assign* to
the other two. For example,

$HTTP_SESSION_VARS['a'] = 'iguana';

simultaneously *assigns* 'iguana' to $a and $_SESSION['a'].

However, unset($a) does NOT unset $HTTP_SESSION_VARS['a'] or $_SESSION['a'],
with two results. One, the value of the session variable, $a, is no longer
in sync with $HTTP_SESSION_VARS['a'] and $_SESSION['a']. Two, $a will have
the value 'iguana' restored on the next session_start(). This is unexpected
behavior and not explained in the manual, AFAIK.

Kirk


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to