Re: SESSION problem
| From: | tedd | Date: | Sat, 16 Aug 2008 12:20:07 +0000 |
| Subject: | Re: SESSION problem | ||
| References: | 1 2 3 4 5 6 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-278220@lists.php.net to get a copy of this message | ||
At 12:40 PM +0100 8/16/08, Stut wrote:
On 16 Aug 2008, at 12:36, tedd wrote:Stut: I was hoping you would join in. But I solved the problem and found a surprising result. The result is you cannot use a number as an index in a $_SESSION, like so: $a = "20"; $_SESSION[$a] = "good morning'; <-- won't work But you can use: $a = "a20'; $_SESSION[$a] = "good night'; <-- will work Furthermore, if you do make that mistake, all other $_SESSION variables declared AFTER the incident will cease to work. Isn't that interesting? Here's an example: http://www.webbytedd.com/b2/session-test1/index.php The code is at the bottom of the page. Please tell me that you didn't know this, for if you do, it will make my day. On the other hand, if you tell me where I it wrong, it will still make my day. :-) Always a pleasure listening to your thoughts and advice. Cheers, tedd -- ------- http://sperling.com http://ancientstones.com http://earthstones.comThe problem here is can I use a variable within a $_SESSION[] declaration? Like so: $_SESSION[$var]I haven't really been following this thread but using a variable like that is perfectly valid. $_SESSION is no different to any other array during the processing of your script, the only difference is that it's stored between requests. -Stut