Re: objects in session

From: Date: Tue, 16 Mar 2004 17:58:12 +0000
Subject: Re: objects in session
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-180572@lists.php.net to get a copy of this message
Marc Serra wrote:
Hi, I got problem when i want to save object in session. I got my first page when I create my object and save it to session: <?php Require 'test.inc.php'; Session_start();
            $test = new test();
            $test->Load($_Get['id']);
            $_SESSION['save'] = $test;
?> In my second page I want to retrieve my object <?php Require 'test.inc.php'; Session_start(); echo get_class($_SESSION['test']); ?> When I do get_class($_SESSION['test']); I got the message "__PHP_Incomplete_Class" instead of "test" Can you explain me where I can have made an error.
What's going on here is that you haven't redefined your class for PHP in the second page. When PHP saves your object, it saves only its data, not its functions and such. Are you sure you're defining your object correctly? Have you tried instantiating a test() object in the second page? -- paperCrane <Justin Patrin>

« previous php.general (#180572) next »