RE: [PHP-GENERAL] Re: [PHP-DEV] Sessions and Objects
| From: | Christopher Thompson | Date: | Sat, 17 Jun 2000 23:56:39 +0000 |
| Subject: | RE: [PHP-GENERAL] Re: [PHP-DEV] Sessions and Objects | ||
| References: | 1 | Groups: | php.dev php.general |
| Request: | Send a blank email to php-dev+get-21649@lists.php.net to get a copy of this message | ||
Replace "page B" with "all pages" and you will understand the problem that
James is having.
I doubt that settype() allows you to set the type using a class name (only
'object'), but if it did you could reset the instance data returned by the
session before you used it.
The current solution, I guess, is to put all of your class definitions in
your prepend file (or include them in every page) to make sure they are
always present. A class is a data type and therefore needs to be _added to
the language_ in a sense.
I would be best if the session saved the class type with the instance
data. There was probably an implementation reason for it to be set to
'stdClass'.
I hope the PHP team is aware that the object support in sessions is not
quite there and can keep improving the already excellent session library.
> -----Original Message-----
> From: Andrei Zmievski [mailto:andrei@ispi.net]
> Sent: Saturday, June 17, 2000 8:25 AM
> To: James Du Russel
> Cc: php-general@lists.php.net; php-dev@lists.php.net
> Subject: [PHP-GENERAL] Re: [PHP-DEV] Sessions and Objects
>
>
> On Fri, 16 Jun 2000, James Du Russel wrote:
> > When PHP 4 restores objects from a session, if the class is
> not defined,
> > the object type reverts to 'stdClass' As long as session_start()
> > happens belows class definitions, the code works fine.
> >
> > Here's the problem. Page A creates an object of some type, and stores
> > it into the session. The user works with page A for a while,
> then moves
> > over to page B. Page B has no requirement for the object created by
> > page A, but the session data is required (for the logged in
> user object)
>
>
> Have page B include a file with class declaration before loading
> session. Even though it has no requirement for that object, it won't
> hurt it to include the declaration so that the object may be properly
> instantiated.
>
> -Andrei
> * We are not a clone. *
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>