RE: SESSION problem

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

 



Been on holiday, so coming to this party a bit late, but....
 
On Sat 16/08/2008 15:06 Stut wrote:
> On 16 Aug 2008, at 14:46, tedd wrote:
> > At 2:11 PM +0100 8/16/08, Stut wrote:
> >> Ahh, I see the problem. You've never been able to use numbers as 
> >> keys at the root level of the $_SESSION array. It's not a bug, it's 
> >> just the way it is. I've just checked the documentation and can't 
> >> find an obvious reference to this limitation which is kinda annoying.
 
Well at http://www.php.net/manual/en/session.examples.php there's a big fat Note at the top of the page which includes the following: "The keys in the $_SESSION associative array are subject to the same limitations as regular variable names in PHP, i.e. they cannot start with a number and must start with a letter or underscore.".
 
[ -- SNIP -- ]

> > Let me play the age-card -- in every language I've programmed in for 
> > the last 43 years an array can have numeric indexes -- except php's 
> > SESSION.
> 
> I wish I understood the reason why it's like this but I've never 
> looked into the session extension in that level of detail, but I doubt 
> such a limitation would exist if there was not a very good reason for 
> it. 

One word suffices here: register_globals! Or, if that doesn't suffice: if register_globals is turned on, all the $_SESSION entries are automatically registered as global variables -- so any numeric indexes will obviously be invalid and will "disappear". For consistency's sake, PHP enforces the restriction even with register_globals off.
 
Cheers!
 
Mike
 
-- 
Mike Ford,  Electronic Information Developer, 
Libraries & Learning Innovation, 
C507, Civic Quarter Campus, Leeds Metropolitan University,
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom 
Email: m.ford@xxxxxxxxxxxxxx            Tel: +44 113 812 4730


To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm

[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