Hi, guys I'm having this problem with storing Objects in the Session.
The Scenario is as follows:
What I do is I fetch a custom built RowSet [similar to ADO Recordset] with Data Items and want to store it in a dpCachedData class object with several additional variables.
I import dpCachedData class definition before I start the session [session.auto_start = 0 in the php.ini]
I instantiate the class with $Cache variable
I get the Rowset [which is alright]
I store the Rowset (and aditional vars) in the Session
While printing stored session class right after I put it there, I can see it is stored alright.
I go to other test page and printing the contents of my session object - the non object vars are alright, but the object is nothing ...
before i attach the samle code i just wanna say that i've been thru lots of posts on the subject and non seem to help, so please an anyone shed a light on this problem ...
The code:
[ dpCachedData.php ]
// ---------------------------------------------------------------------------------------
// class DPCachedData
//
// Doesn't have custom error handling.
// ---------------------------------------------------------------------------------------
class DPCachedData
{
var $m_rowSet; //_ DataItemSet object
var $m_rootGUID; //_ DIS' root GUID if available
var $m_currentPosition; //_ Last browsing of the set started here
// -------------------------------------------------------------------------------
// Constructor:
// + registers the destuctor function
// -------------------------------------------------------------------------------
function DPCachedData()
{
register_shutdown_function(array(&$this, "Close"));
return true;
}
// -------------------------------------------------------------------------------
// Desctructor:
// + closes & the XML objects and all
// -------------------------------------------------------------------------------
function Close()
{
if (isset($this->m_rowSet)) {unset($this->m_rowSet);}
if (isset($this->m_rootGUID)) {unset($this->m_rootGUID);}
if (isset($this->m_currentPosition)) {unset($this->m_currentPosition);}
return true;
}
} //_ EOC: DPCachedData
···································································································
[ testSession_1.php ]
// _ requires DPCachedRowSet class definition
require_once("DPCachedData.php");
session_start();
$DPData; //_ DPDataFetcher class object
$XMLWrapper; //_ DPXMLDataWrapper class object
$parentID; //_ Data Item parent DBID
$startPos; //_ Paging start position
$pageSize; //_ Page length
$RURS; //_ DataItemSet reusable recordset
// _ requires DBDataFether class definition
require_once("DPDataFetcher.php");
// _ requires DPXMLDataWrapper class definition
require_once("DPXMLDataWrapper.php");
// _ instantiate a DBDataFether class object
$DPData = new DPDataFetcher();
$parentID = $_REQUEST["guid"];
//_ if no parameter recieved - die with no response
if (empty($parentID)) {die();}
$startPos = $_REQUEST["start"];
//_ if no parameter recieved - set default
if (empty($startPos)) {$startPos = 0;}
$pageSize = $_REQUEST["psize"];
//_ if no parameter recieved - set default
if (empty($pageSize)) {$pageSize = $_SESSION["DEF_PAGING_SIZE"];}
//_ fetch an object from Session
$Cache = new DPCachedData;
$Cache = &$_SESSION["CACHED_DATA_OBJECT"];
//_ retrieves raw data into an Data Item Set
$RURS = $DPData->GetAllDataForRoot($parentID);
$Cache->m_rowSet = $RURS;
$Cache->m_rootGUID = $parentID;
$Cache->m_currentPosition = $startPos;
$_SESSION["CACHED_DATA_OBJECT"] = $Cache;
//_ irrelevant code ...
···································································································
[ testSession_2.php ]
// _ requires DPCachedRowSet class definition
require_once("library/DPCachedData.php");
session_start();
$obj=&$_SESSION["CACHED_DATA_OBJECT"];
print_r($obj);
echo "<hr />";
echo $obj->m_rootGUID . "<br />";
echo $obj->m_currentPosition . "<br />";
print_r($obj->m_rowSet);
$obj->m_rowSet->MoveFirst();
echo $obj->m_rowSet->Name . " EOF? " . $obj->m_rowSet->EOF;
The output:
stdClass Object ( [m_rowSet] => COM Object ( [0] => 0 ) [m_rootGUID] => {E3CB7B18-B218-4ACB-85EE-5007D20908AB} [m_currentPosition] => 0 )
{E3CB7B18-B218-4ACB-85EE-5007D20908AB}
COM Object ( [0] => 0 )
EOF?
in short the m_rowSet member gives NADA!!!
if anyadditional information is needed ask away!!!
any comment is appreciatate, thanks.