|
Posted by Jochem Maas on 03/30/05 16:48
Chris wrote:
> Richard Lynch wrote:
>
>>
>>
>> On Tue, March 29, 2005 7:58 pm, Chris said:
>>
>>
>>> Richard Lynch wrote:
>>>
>>>
....
>>>
>>> Are you sure you don't have register_globals enabled?
>>>
I tested Richards reproduce script on php 5.0.3 on a Debian
machine with the following ini settings:
register_globals = Off
register_long_arrays = Off
register_argc_argv = Off
magic_quotes_gpc = Off
magic_quotes_runtime = Off
(i.e. all relevant ini settings are php5 defaults)
and I get the same freakin' references from/in the SESSION array.
>>
>>
>> Actually, they *ARE* enabled by my webhost.
>>
>> I don't really think that's relevant, however, as PHP is storing $name
>> back *IN* to my $_SESSION data, just because I did:
>> $name = $_SESSION['name'];
>> $name = "Fooey";
>>
>> $name is a STRING.
>>
>> It's not an object.
>>
>> It should *NOT* be a Reference!
>>
>> But it is a Reference, so changing $name alters $_SESSION['name']
>>
>>
>>
> Sorry, meant to reply to list, not just you.
>
> All I'm saying is that Sessions act extremely oddly with
> register_globals enabled.
>
> With register_globals on I believe the global variable, acts as a
> reference. It's not because it's a string, it's because it's a session
> variable, and it needs to keep track of changes to the variable.
I agree with Chris that register_globals can only cause more pain and misery :-/
but in this case the problem exists regardless of register_globals setting.
here is a func I sometimes use when going to war with a register_globals=On server :-)
nothing special and I blagged the idea from somewhere/someone (probably in the
user comments somewhere in the php manual :-/)
function unRegisterGlobals()
{
if (ini_get('register_globals')) {
$SGs = array($_SERVER, $_ENV, $_FILES, $_COOKIE, $_POST, $_GET);
if (isset($_SESSION)) { array_unshift($SGs, $_SESSION); }
// SG == super global
foreach ($SGs as $sg) {
foreach ($sg as $k => $v) { unset($GLOBALS[ $k ]); }
}
ini_set('register_globals', false);
}
}
>
[Back to original message]
|