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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: yzhang at sfu dot ca
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 15:01:32 2024 UTC