Salve, sto cercando di salvare un oggetto in una variabile di sessione $_SESSION per poterlo poi riutilizzare successivamente.
Riporto qui sotto il codice in questione:
Codice PHP:
require_once('VFSclient.class.php');
session_start();
if (isset($_POST['submit'])) {
switch ($_POST['submit']){
case 'Entra':
//LOGIN
if(doLogin($_POST['username'], $_POST['password'])){
//LOGIN OK
echo "Login OK - USER = ".$_POST['username']." - PASS = ".$_POST['password']. " - TKEY = ".$_SESSION['vfs']->tkey;
//header("Location: main.php");
} else {
//LOGIN ERROR
$_POST['errmsg'] = $_SESSION['vfs']->getErrorMessage();
include('login.php');
}
break;
case 'Registrati':
//VISUALIZZA PAGINA DI REGISTRAZIONE
include('register.php');
break;
case 'Procedi':
//EFFETTUA REGISTRAZIONE
if(doRegister($_POST['username'], $_POST['password'], $_POST['email'])){
// USERADD OK - NOW LOGIN
include('login.php');
} else {
//FALLISCE LA USERADD
}
break;
}
} else {
//PRIMA VOLTA CHE ACCEDO - CREO L'OGGETTO VFSClient()
$_SESSION['vfs'] = new VFSClient();
include('login.php');
}
function doLogin($username, $password){
return $_SESSION['vfs']->login($username,$password);
}
function doRegister($username, $password, $email){
return $_SESSION['vfs']->userAdd($username,$password,$email);
}
Questo codice però contiene qualcosa che non va, infatti, ogni volta che tento di eseguire le operazioni effettuate dalle funzioni doLogin e doRegister php risponde con:
Fatal error: VFSClient::login() [function.VFSClient-login]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "WebService_VFSiService_VFService" 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 C:\Programmi\Apache Software Foundation\Apache2.2\htdocs\VFSclient\VFSclient.cl ass.php on line 49
Qualcuno saprebbe dirmi cosa sto sbagliando?
Ciao,
Samuele.