php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12230 Error with Object saved in Session
Submitted: 2001-07-18 09:36 UTC Modified: 2001-11-18 01:24 UTC
From: schmidt at ibou dot de Assigned:
Status: Closed Package: Session related
PHP Version: 4.0.5 OS: HP Unix 10
Private report: No CVE-ID: None
 [2001-07-18 09:36 UTC] schmidt at ibou dot de
I have the follow Problem:

Fatal error:  The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition test of the object you are trying to operate on was loaded _before_ the session was started in /u4_1/www/rf/includes/all_sicherheit.inc on line 3

Very simple:

In file 1:

class foo
{
...
}
$x=new foo
$x->... = 123;
session_register("x");

in 2. file:

class foo
{
...
}

echo $x->...;

When I do a session_register("x") befor I printed $x->...
it get the same error.

Is there a Workaround?

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-11-18 01:24 UTC] sebastian@php.net
This is not a bug. Please have a look at the error message: 'The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition test of the object you are trying to operate on was loaded _before_ the session was started'.

 [2004-07-09 00:26 UTC] jason at thewebmark dot com
I would like to reaffirm that this is a bug, I've had the same problem storing objects in the session using PHP Version 4.3.4.

My work around for the this problem was serializing the object  and placing the resulting string in the session, and manually unserializing the object after pulling the string from the session.

This bug appeared on the production environment running the php CGI on winnt

This bug did NOT appear in my dev environment running php ISAPI, Ill be more than happy to provide init files and any other requested info.


----------------------------------------------------------

	class Tester {
		function TestFunc() {
			echo "PHP is Busted";
		}
	}

	session_start();

	if(isset($_REQUEST[init])) {
		$us = new Tester();
		
		$_SESSION[x] = serialize($us);
		
		//
		//$_SESSION[x] = $us;
	}
	else {
		
		$b = unserialize($_SESSION[x]);

		// 
		//$b = $_SESSION[x];

		print_r($b);
	}

-------------------------------------------------------
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 17 02:01:32 2024 UTC