Re: [PHP-DEV] PHP 4.0 Bug #4285: Unexpected warning using an object in a session From: Sascha Schumann (sascha <email protected>)
Date: 04/30/00

On Mon, May 01, 2000 at 02:13:58AM -0000, yzhang <email protected> wrote:
> From: yzhang <email protected>
> Operating system: Linux (Redhat 6.0)
> PHP version: 4.0 Release Candidate 1
> PHP Bug Type: Session related
> Bug description: Unexpected warning using an object in a session
>
> An unexpected warning comes back when I use an object in a session variable:
>
> The code is this:
>
> <?
> error_reporting(15);
> session_start();
> session_register("SESSION");
>
> if (! isset($SESSION)) {
> class object {};
> $SESSION = new object;
> $SESSION->i = 5;
> } else {
> echo "My value is: $SESSION->i";
> }
> ?>
>
> Run it twice (first time to register the session, the second time to use it) and you will see this:
>
> Warning: Unserializing non-existant class: stdClass! No methods will be available! in /home/httpd/htdocs/test.php on line 3
> My value is: 5
>
> Not sure why this is a warning, what is stdClass? I find no mention of it in the manual.

The class definition must be available to the session engine.
Otherwise it won't be able to deserialize an object properly.

In this case, you need to move the class .. line before
session_start().

- Sascha

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>