php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #4285 Unexpected warning using an object in a session
Submitted: 2000-05-01 04:13 UTC Modified: 2000-05-13 07:57 UTC
From: yzhang at sfu dot ca Assigned:
Status: Closed Package: Session related
PHP Version: 4.0 Release Candidate 1 OS: Linux (Redhat 6.0)
Private report: No CVE-ID: None
 [2000-05-01 04:13 UTC] yzhang at sfu dot ca
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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-05-13 07:57 UTC] thies at cvs dot php dot net
please make the class definition always available to your script!

in you case "class object" is only available is $SESSION is not set!
moving:
class object{};
before the if statement will solve yor problem

 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu Aug 11 09:06:03 2022 UTC