RE: [PHP] SESSION problem
| From: | Ford, Mike | Date: | Tue, 19 Aug 2008 23:55:29 +0000 |
| Subject: | RE: [PHP] SESSION problem | ||
| References: | 1 2 3 4 5 6 7 8 9 10 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-278370@lists.php.net to get a copy of this message | ||
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@leedsmet.ac.uk 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