note 30231 added to ref.session
| From: | tech at rack1 dot php dot net | Date: | Tue, 11 Mar 2003 19:14:27 +0000 |
| Subject: | note 30231 added to ref.session | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-45108@lists.php.net to get a copy of this message | ||
hey everyone, an important CAUTIONARY TALE that might save you much frustration:
when i was setting
> $_SESSION[<array>][<key>] = <value>;
in my code, i noticed the array disappeared on next page load; within the page load where it was
set, accessing $_S[a][k] return <value>, but i'd go to another page and $_S[a] was NULL!
I really can't explain why, but $_S[a] had to ALREADY BE AN ARRAY when a key=>value pair was
added to it. SO, to make a long story short, since my array was 1-based, I called the declaration
> $_SESSION[<array>][0] = "anchor" ;
every time the session was initialized on log-in. that way, $_S[a][<int of 1 or more>] would
always ADD TO an already existing array, and then the array persisted between pages!
hope that helps,
__tech
--
http://www.php.net/manual/en/ref.session.php
http://master.php.net/manage/user-notes.php?action=edit+30231
http://master.php.net/manage/user-notes.php?action=delete+30231
http://master.php.net/manage/user-notes.php?action=reject+30231