For whatever reason, I can't seem to get objects in sessions to work. I've read countless reminders to make sure that the class is finalized before the session is started, but I'm pretty sure I've done that correctly. Here's some test code I wrote:
<?
class session_class {
var $str = '<br>This is $obj->str' ;
}
session_start() ;
if( !isset($obj) ) {
$obj = new session_class() ;
session_register('obj') ;
}
print ( '$obj is an ' . $obj . ' of class ' . get_class($obj) ) ;
print $obj->str ;
?>
Its output is as follows:
$obj is an Object of class session_class
This is $obj->str
After refreshing, its output becomes:
$obj is an Object of class __PHP_Incomplete_Class
Fatal error: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition session_class of the object you are trying to operate on was loaded before the session was started in c:\www\public_html\test\test.php on line 15
I can't understand what could possibly be causing this, since clearly the Object is being recognized as an Object the second time around, and clearly the class is well defined and previous to the session_start(). I can't imagine this could be a problem somewhere in my php.ini? Any ideas?