note 55608 modified in function.eval by danbrown
| From: | danbrown@php.net | Date: | Tue, 25 Nov 2008 16:06:19 +0000 |
| Subject: | note 55608 modified in function.eval by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-146941@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
<?php
addslashes(var_export($_SESSION, TRUE))
?>
To restore it, I executed this code:
<?php
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.
--was--
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.
http://php.net/manual/en/function.eval.php