note 55608 added to function.eval
| From: | jphansen at uga dot edu | Date: | Mon, 08 Aug 2005 19:43:37 +0000 |
| Subject: | note 55608 added to function.eval | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-93270@lists.php.net to get a copy of this message | ||
I used eval() to restore a user's session data. I stored $_SESSION to a field in a database as
<?
addslashes(var_export($_SESSION, TRUE))
?>
To restore it, I executed this code:
<?
eval("\$_SESSION = $session;");
// $session being the first line of code above
?>
Voila! Session restored.
Without eval(), $_SESSION = $session would have resulted in $_SESSION being a string instead of an
array.
----
Manual Page -- http://www.php.net/manual/en/function.eval.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+55608
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55608&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55608&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55608&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55608&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55608&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55608&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+55608&report=yes
Search -- http://master.php.net/manage/user-notes.php