Re: How to preserve object with session
| From: | Teodor Cimpoesu | Date: | Fri, 07 Jul 2000 14:20:25 +0000 |
| Subject: | Re: How to preserve object with session | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-5387@lists.php.net to get a copy of this message | ||
Hi Przem!
On Fri, 07 Jul 2000, Przem Kowalczyk wrote:
>
>
> > -----Original Message-----
> > From: Teodor Cimpoesu [mailto:teo@digiro.net]
> > Sent: Friday, July 07, 2000 3:46 PM
> > To: Php4
> > Subject: Re: [PHP] How to preserve object with session
> >
> > Hi Przem!
> > On Fri, 07 Jul 2000, Przem Kowalczyk wrote:
> >
> > > Hi
> > >
> > > I know, that sessions don't preserve object's methods.
> > half true.
> > If you have the class definition at the unserialization time
> > you'll have the methods too i.e.
> > include 'class_definition.inc';
> > session_start();
>
> Oki. A working example:
>
> include ("class.Job.php");
>
> session_register('job');
> if (!is_object($job))
> {
> $job = new Job('job','BODY');
> }
> echo "back: " .$job -> test . "<br>";
> $job -> test++;
> $job -> set_block('employee','EMPLOYEE');
> $page = new Page('page');
> $page -> set_child($job);
> $page -> eParse();
> $page -> ePrint();
>
>
> if i reload the page i got:
>
> Fatal error: Call to undefined function: set_block() in
> /www/virtual/przem/b2b/htdocs/jobs/employee.php on line 11
hmm, looks like it tries to call the set_block() function not
the method (for an unknown method the error message is different, IIRC)
can you include the class definition(s) in one file and provide
a `reproduceable' example?
(e.g. in vi,
:1 r class.Job.php'. Also where is your Page'
class defined?)
-- teodor