note 55634 added to ref.session
| From: | jphansen at uga dot edu | Date: | Tue, 09 Aug 2005 12:19:26 +0000 |
| Subject: | note 55634 added to ref.session | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-93307@lists.php.net to get a copy of this message | ||
I found the easiest method of saving and restoring a user's session data was storing $_SESSION
to a database:
<?
addslashes(var_export($_SESSION, TRUE))
?>
Then restoring it using eval():
<?
eval("\$_SESSION = $session;");
// $session = the first line of code above
?>
Without eval(), $_SESSION = $session would have resulted in $_SESSION being a string instead of an
array.
----
Manual Page -- http://www.php.net/manual/en/ref.session.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55634
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55634&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55634&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55634&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55634&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55634&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55634&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55634&report=yes
Search -- http://master.php.net/manage/user-notes.php