ok, allora proverei una cosa del genere:

Codice PHP:
//implemetare questi metodi 
class User 
{
public function 
__sleep() {
// actions to perform when serialized (e.g. close database connection)
}

public function 
__wakeup() {
// actions to perform when unserialized (e.g. reopen database connection)
}
}

//dove crei la sessione e recuperi i dati utente
$_SESSION['object'] = serialize(new User());

//in html/index.php
$object unserialize($_SESSION['object']); 
Guarda qui per i magic method:


http://www.php.net/manual/en/language.oop5.magic.php

Forse potresti provare un casting, ma questo non l'ho ancora verificato :

Codice PHP:
<?php
function cast_class($object$newclass)
{
    if( !
is_object($object) )
    {
        
trigger_error('cast_class expects parameter 1 to be object, ' gettype($object) . ' given'E_USER_WARNING);
        return 
false;
    }
    if( !
class_exists($newclass) )
    {
        
// We'll save unserialize the work of triggering an error if the class does not exist
        
trigger_error('Class ' $newclass ' not found'E_USER_ERROR);
        return 
false;
    }
    
$serialized_parts explode(':'serialize($object));
    
$serialized_parts[1] = strlen($newclass);
    
$serialized_parts[2] = '"' $newclass '"';
    return 
unserialize(implode(':'$serialized_parts));
}


?>

$newclass = 'la tua classe user';
$userData = cast_class($object, $newclass);
occhio perchè serializzare un oggetto in PHP non è molto semplice: controlla anche che il costruttore della classe user, che dovrebbe essere qualcosa tipo:

Codice PHP:
private $_dato1;
private 
$_dato2;

public function 
__construct($d1$d2) {

   
$this->_dato1 $d1;
   
$this->_dato2 $d2;