Re: Legal $_SESSION names

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2009/5/22 tedd <tedd@xxxxxxxxxxxx>:
> Hi gang:
>
> While we're discussing what's legal in css, here's a couple of things I've
> found about sessions.
>
> I found that starting a session with a number doesn't work.
>
> $myvar = $_SESSION['1myvar'];

This won't work because $1myvar is not a valid variable. I believe the
only reason this restriction is in place due to register_globals. I
dunno if this restriction has been lifted since register_globals being
removed from PHP6 but of all the "annoyances" in PHP this is a pretty
minor example.

> I also found that dumping a session to a variable with the same name may
> cause problems, such as:
>
> $myvar = $_SESSION['myvar'];
>
> Regardless of what anyone may say to the contrary, it doesn't work
> everywhere. I found that out the hard way. The fix is simply to use a
> different name for the variable, such as:
>
> $my_var = $_SESSION['myvar'];

I'm just guessing but I'd say this has to do with the way superglobals
are created. Since 5.0.0 a configuration option called
auto_globals_jit has existed and it defaults to being on. It causes
the creation of superglobals to be delayed until they are actually
used. I don't know how it interacts with register_globals (the manual
says it'll be disabled if register_globals is on) but it makes sense
to me that this issue is related to that.

I'd say you've found a bug, but you'll need a repeatable example
before you can report it.

-Stuart

-- 
http://stut.net/

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux