Hi there all!
I am having a problem with using classes with session. what i want to do is save an object onto the session which is no problem. the class of the object has a constructor and i am using this constructor on the page that i register the object on. the problem is that when i come back to this page later the constructor is being called again and i am losing the fields in the object. so my code is like this:
someClass.inc:
class someClass{
var $aField;
function someClass($mField){
$this->aField = $mField;
}
... rest of the class
}
aPage.php:
include("someClass.inc");
session_register("MyObject");
$MyObject = new someClass(10);
... rest of the page
if i change $MyObject->aField somewhere (maybe on this page) and then come back to this page, the object is re-initialised. i have tried this:
aPage.php:
include("someClass.inc");
if(!session_is_registered("MyObject")){
session_register("MyObject");
$MyObject = new someClass(10);
}
... rest of the page
but i get the error about trying to call a function that does not exist i.e. did not recognise or find the class.
Any help would be greatly appreciated. Thanks.
Ziad