I think, its not possible to init an Objeect on a session. Session will be 
rebuild on each reload of the site based on the session id, i think...

Maybe here the object can't be rebuild anymore...
> Following code:
>
> <?php
>
> class SessionTestC {
>     protected $value;
>
>     function __construct ( $val ) {
>         $this->value = $val;
>     }
>
>     function GetValue () {
>         return $this->value;
>     }
> }
>
> if ( isset ($_SESSION['TestObj'])) {
>     echo 'Session Test is set to:
> '.$_SESSION['TestObj']->GetValue().'<br>'; } else {
>     session_start ();
>     echo 'Session Test was not set.<br>';
>     $_SESSION['TestObj'] = new SessionTestC ( 'This is a test' );
>     echo "<a href='".basename($_SERVER['PHP_SELF'])."'>Click
> here.</a><br>"; }
>
> ?>
>
> Gives me an error of incomplete object on second access, like this:
>
> *Fatal error*: main() [function.main
> <http://localhost/sfcms/Scripts/function.main>]: The script tried to
> execute a method or access a property of an incomplete object. Please
> ensure that the class definition "SessionTestC" of the object you are
> trying to operate on was loaded _before_ unserialize() gets called or
> provide a __autoload() function to load the class definition in
> */home/fmmarzoa/Develop/Stradivarius/Scripts/SessionTest.php* on line *16
>
> *But as it can be seen, the class is defined in the script
> SessionTest.php itself, so... ??????

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to