Re: Legal $_SESSION names

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

 



On Fri, 2009-05-22 at 12:01 -0400, tedd wrote:
> At 4:52 PM +0100 5/22/09, Ashley Sheridan wrote:
> >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
> 
> 
> Ash:
> 
> You are right, but here's the rub -- when you have register globals 
> turned on and you use:
> 
> $myvar = $_SESSION['myvar'];
> 
> This sometimes works and sometimes fails. I had an entire site where 
> I had been using the same names for attributes and variables 
> throughout and suddenly one page didn't work. All other pages worked 
> just fine, but this single page didn't.
> 
> I searched high and low for an answer and found a vague reference 
> where someone else had run into a similar problem and found the 
> solution was to change the variable name. So I did with that single 
> page and everything worked.
> 
> Why did that single page not work and everything else did? I haven't 
> a clue, but I will say that I reduced the problem to that 
> specifically and that *was* the problem.
> 
> Additionally, why was that problem not realized in the other pages on 
> the same site -- I don't know, but this was an example of "sometimes 
> it works, and sometimes it doesn't" -- a heck of a way to run a 
> railroad.
> 
> Cheers,
> 
> tedd
> -- 
> -------
> http://sperling.com  http://ancientstones.com  http://earthstones.com
> 
It's an odd one, no doubt about that! 


Ash
www.ashleysheridan.co.uk


-- 
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