Justtechjobs.com Find a programming school near you






Online Campus Both


php-developer-list | 2001122

RE: [PHP-DEV] Bug in 4.1.0; _SESSION From: Andreas Aderhold (a.aderhold <email protected>)
Date: 12/21/01

Hi Zeev,

> Can you provide a full code snippet that hangs? This code
> snippet doesn't appear to hang, are you running it in a
> function context?

Either. I additionally discovered that it hangs only if the session has
not been created by a prior page call. So, deleting all /tmp/sess_*
files, restarting browser, calling test.php with this contents. Hangs.

<?php
global $_SESSION;
session_start();

phpinfo();
?>

As well as in a function context:

<?php

function TestStart()
{
    global $_SESSION;
    session_start();
}

TestStart();
phpinfo();

?>

If I switch the session_start() function and the global $_SESSION
statement it works.

So it occurs to me that declaring global does not work unless the
session module has created the $_SESSION var. Or vice versa: mod session
has problems creating $_SESSION after it has been declared global.

Initialising $_SESSION at the very top of the script (i.e. $_SESSION =
0) has no effect at all.

This happens on Linux/Apache as well as on NT/IIS.

Best,
Andi

--
www.binarycloud.com

Zeev

At 14:59 21/12/2001, Andreas Aderhold wrote: >Hi All, > >found a bug > >this one will cause a infinte loop in 4.1: ><?php >global $_SESSION; // this will cause a infinite loop session_start(); >phpinfo() >?> >Te docs say that $_SESSION is auto-global in 4.1.0 but it does not say, that >the explicit global declaration is not allowed. However I would like to use >the explicit global declaration for improved code readbility. > >Andi > >-- >www.binarycloud.com > >

-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, e-mail: php-dev-unsubscribe <email protected> For additional commands, e-mail: php-dev-help <email protected> To contact the list administrators, e-mail: php-list-admin <email protected>