Serializing objects and storing them is sessions
| From: | Jason Giangrande | Date: | Thu, 08 Apr 2004 18:10:55 +0000 |
| Subject: | Serializing objects and storing them is sessions | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-182880@lists.php.net to get a copy of this message | ||
I'm having a problem unserializing objects that are passed from page to page with sessions. Registered globals is disabled so I am using the $_SESSION array to store session variable and am not using session_register(). Here's what I'm doing.
On first page:
$auth = new Class();
session_start();
$_SESSION['auth'] = serialize($auth);
Second page:
session_start();
var_dump($_SESSION);
$auth = unserialize($_SESSION['auth']);
var_dump($auth);
When I var_dump() $_SESSION it appears to be a string representation of the object. However, when I try to unserialize() it and store it in $auth the value is bool(false) and not an object.
Can anyone tell me what I am doing wrong?
Thanks,
--
Jason Giangrande <jason@giangrande.org>
http://www.giangrande.org
http://www.dogsiview.com