PHP 4.0 Bug #6700 Updated: Problem With Objects as Session Variables

From: Date: Wed, 13 Sep 2000 03:30:56 +0000
Subject: PHP 4.0 Bug #6700 Updated: Problem With Objects as Session Variables
Groups: php.dev 
Request: Send a blank email to php-dev+get-33076@lists.php.net to get a copy of this message
ID: 6700 User Update by: dkm@cwcom.net Status: Open Bug Type: *Session related Description: Problem With Objects as Session Variables I missed out the require statement in second.php. The actual script is: second.php ========== <? require("person.inc"); session_start(); ?> <html> <head> <title>Second</title> </head> <body> <? $aperson->display_details(); ?> </body> </html Previous Comments: --------------------------------------------------------------------------- [2000-09-12 23:01:39] dkm@cwcom.net My problem appears to be the same as Bug id #6604 which, as yet, has received no feedback. While simple variables work fine, I receive the following error with the example scripts below: "Fatal error: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition person of the object you are trying to operate on was loaded _before_ the session was started in /usr2/www/test/sessions/second.php on line 6" If I use $ser_aperson = serialize($aperson) in first.php and unser_aperson = unserialize($ser_aperson) then unser_aperson->print_details() works fine. I understand that serialization of objects should be handled automatically by the session module. person.inc ========== class person { var $first_name = "John"; var $surname = "Smith"; function display_details() { print("First Name: ". $this->first_name. "<br>"); print("Surname: ". $this->surname. "<br>"); } } first.php ========= <? require("person.inc"); session_start(); session_register(aperson); $aperson = new person; ?> <html> <head> <title>First</title> </head> <body> <a href="second.php">Second</a> </body> </html> second.php ========== <? session_start(); ?> <html> <head> <title>Second</title> </head> <body> <? $aperson->display_details(); ?> </body> </html --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=6700

« previous php.dev (#33076) next »