php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #13298 Object unserialization and session_start
Submitted: 2001-09-14 06:06 UTC Modified: 2001-11-18 01:31 UTC
From: dastolfo at smart dot it Assigned:
Status: Not a bug Package: Session related
PHP Version: 4.0.6 OS: any
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dastolfo at smart dot it
New email:
PHP Version: OS:

 

 [2001-09-14 06:06 UTC] dastolfo at smart dot it
I saw many reports about object serialization/unserialization and I want to clarify what I understood.

Let's say you have the file 'foo.php' that defines the class 'foo':
<?php

class foo {
  var $bar = 0;
  function foo() {
    $this->bar = 1;
  }
}
?>

and another file that uses this class:
<?php
include_once 'foo.php';

start_session();
if(!isset($f)) {
        $f = new foo();
        session_register('f');
        print "New object<br>";
}
else {
        $f->bar = 5;
        print "Object from session<br>";
}

?>
This code works, but if I:
1) put start_session() BEFORE the inclusion of foo.php
2) execute some code BEFORE the inclusion of foo.php
3) set session.auto_start to 1 in php.ini

I will receive this error:
Fatal error: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition foo of the object you are trying to operate on was loaded _before_ the session was started in ... 

This is due to the fact that in the moment you execute even a single line of code php starts the unserialization.

In practice, with this behaviour, it's impossible to work with object in session with session.auto_start set.

Will there be a workaround or a solution to this problem?

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-18 01:31 UTC] sebastian@php.net
This is not a bug.

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 19:01:28 2024 UTC