I have a project where on the initial page I initialize two objects, a dB obj and a fileHandler obj. The dB object is initialized and then then the fileHandler obj is initialized, with a mysqli object returned from one of the dB objects methods (getMysqli()) passed in as a parameter. What I would like to do is save these objects in a session for use on other pages. When I assigned these instances to a session var like so:
$_SESSION[‘fileHandler’] = $fileHandlerObj;
I was able to access get methods to read properties of the object on another page via the session variable, but I wasnt able to execute methods in fileHandler code that called upon the mysqli object methods, such as query for example. The error I received was:
Fatal error: Call to a member function getMysqli() on a non-object in …
So obviously the object I passed into the fileHandler at initialization didn’t get carried over into the session variable. I have tried serializing/unserializing but nothing has produced different results. I am using PHP5, but persistent objects is somewhat new to me so Im sure there is something stupid I am overlooking. Any help would be appreciated, thanks.