I can't mantain objects references after serialize/unserialize operations
this is a code sample:
Code: Select all
<?php
class myclass {
var $a;
function myclass(){
$this->a = ""; //empty
}
}
session_start();
if(!isset($_SESSION['test'])){
$test = new myclass;
$test1 = &$test; //this is a reference to '$test'
$test1->a = "test ok"; //now it's ok, '$test1' point to '$test'
//serialization
$_SESSION['test'] = serialize($test);
$_SESSION['test1'] = serialize($test1);
} else {
//after a page refresh I can unserialize variables but ...
$test = unserialize($_SESSION['test']);
$test1 = unserialize($_SESSION['test1']);
$test->a = "test";
$test1->a = "test1"; //now 'a' member variable is contained in a NEW OBJECT of type myclass !!!
}
?>