note 69131 deleted from faq.misc by betz
| From: | betz@php.net | Date: | Thu, 24 Aug 2006 09:30:19 +0000 |
| Subject: | note 69131 deleted from faq.misc by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-116254@lists.php.net to get a copy of this message | ||
Note Submitter: pscsuk at NOSPAM dot gmail dot com
----
Remember that 'globalizing' $_SESSION like this only does half the job. It makes
"read-only" globals. Any changes you make don't get written back to $_SESSION when
the script ends.
You either have to do that manually, or, instead do something like:
$MyVar = &$_SESSION['MyVar'];
This makes $MyVar into a reference for $_SESSION['MyVar'], so, every time you change
$MyVar, it really changes the value in $_SESSION - thus, at the end of the script, when $_SESSION
gets saved, your changes get saved as well.