Re: Legal $_SESSION names
| From: | Ashley Sheridan | Date: | Fri, 22 May 2009 15:52:09 +0000 |
| Subject: | Re: Legal $_SESSION names | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-292967@lists.php.net to get a copy of this message | ||
On Fri, 2009-05-22 at 11:30 -0400, tedd wrote:
> 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'];
>
> 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'];
>
> Hopes this help someone.
>
> Cheers,
>
> tedd
> --
> -------
> http://sperling.com
> http://ancientstones.com
> http://earthstones.com
>
The second case won't work if you have register globals turned on I
believe, as it will attempt to create $_SESSION['myvar'] as $myvar. I
believe that RG might have something to do with the first as well. I
seem to remember a thread a while back talking about sessions not being
able to use numbered indexes because they are a special super global.
Ash
www.ashleysheridan.co.uk