Reputation: 27
First (to supress the flamers) This link does not answer my question - a minimum it was not helpful Storing XML object in PHP Session Variables
The following WAS a little more helpful as, unlike the above, gave an example
Uncaught exception 'Exception' with message 'Serialization of 'SimpleXMLElement' is not allowed'
I tried that, did not work.
$obj = simplexml_load_string(path/to/xml/file)
$_SESSION[somevar] = $obj
Using this elsewhere produced an exception error which led me to the above link. More research says that you cannot store xml in a php session var, if this is true, is there a way to use it from page to page. The record I pull from my xml files are small, so sql would be an over kill. But for the curious,
the script just pulls one game record with a dozen fields, then uses the info to display on a page. The pages are accessed dynamically so various pages do diferent things with the data.
one idea I have is: would it be worth while to create a function to call the record when needed and manipulate it from there?
ps If this is a moot question or annoying one, please do not answer - I searched for many hours yesterday, and I was disappointed by the sarcasm in many of the responses given, responses that either did not answer the question, or they themselves asked the OP questions that did not pertain to the question - this clutters up SO for us looking for answers. I did do some research, and finally here to check with those that are knowledgeable and may shed some light on a different angle.
Thanks
Upvotes: 0
Views: 1855
Reputation: 4192
You can save instead object its serialized string $xml->asXML();
//set
$_SESSION['xml'] = $xml->asXML();
//get
$xml = new SimpleXMLElement($_SESSION['xml']);
Upvotes: 1