Re: [PHP4BETA] Sessions and Objects
[email protected] (Andrei Zmievski)
| Newsgroups | php.version4 |
|---|---|
| Message-ID | <[email protected]> |
On Thu, 18 May 2000, Dave wrote:
> I just started looking again at using objects in sessions and it appears
> with the latest RC that object serialization does not support serialization
> of methods yet...not that I ever heard that it would..or not.
>
> I caught somewhere that since PHP serialization does support object
> properties that if the class is defined before a session_start() that you
> should be able to have the entire object back...including methods...is this
> the case? or no?
Yes, it is possible. Example:
<?
# save session
include "foo.class.php";
session_start();
session_register("a");
$a = new foo;
$a->bar = 10;
?>
<?
# restore session
include "foo.class.php";
session_start();
var_dump($a);
?>
The second piece of code should print out your class and the methods
should be available.
-Andrei
The church is near but the road is icy;
the bar is far away but I will walk carefully. -- Russian proverb