Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8482069
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:43:47+00:00 2026-06-10T19:43:47+00:00

I need to save an XML object to a PHP session. Apparently this is

  • 0

I need to save an XML object to a PHP session. Apparently this is not possible. I have therefore tried to convert the object to a string and an array and then convert back to an simple XML object but whatever I try does not seem to be working. I just get back empty objects as the var_dump() shows below. Can anyone help.

$messages = $this->Message->getAll('50');  //this functions brings back a simplexml object
$_SESSION['messages'] =  $messages->asXML();  //doesn't work            
var_dump($messages);


array(50) {
  [0]=>
  object(SimpleXMLElement)#5 (0) {
  }
  [1]=>
  object(SimpleXMLElement)#6 (0) {
  }
  [2]=>
  object(SimpleXMLElement)#7 (0) {
  }
  [3]=>
  object(SimpleXMLElement)#8 (0) {
  }
  [4]=>
  object(SimpleXMLElement)#9 (0) {
  }
  [5]=>
  object(SimpleXMLElement)#10 (0) {
  }
  [6]=>
  object(SimpleXMLElement)#11 (0) {
  }
  [7]=>
  object(SimpleXMLElement)#12 (0) {
  }
  [8]=>
  object(SimpleXMLElement)#13 (0) {
  }
  [9]=>
  object(SimpleXMLElement)#14 (0) {
  }
  [10]=>
  object(SimpleXMLElement)#15 (0) {
  }
  [11]=>
  object(SimpleXMLElement)#16 (0) {
  }
  [12]=>
  object(SimpleXMLElement)#17 (0) {
  }
  [13]=>
  object(SimpleXMLElement)#18 (0) {
  }
  [14]=>
  object(SimpleXMLElement)#19 (0) {
  }
  [15]=>
  object(SimpleXMLElement)#20 (0) {
  }
  [16]=>
  object(SimpleXMLElement)#21 (0) {
  }
  [17]=>
  object(SimpleXMLElement)#22 (0) {
  }
  [18]=>
  object(SimpleXMLElement)#23 (0) {
  }
  [19]=>
  object(SimpleXMLElement)#24 (0) {
  }
  [20]=>
  object(SimpleXMLElement)#25 (0) {
  }
  [21]=>
  object(SimpleXMLElement)#26 (0) {
  }
  [22]=>
  object(SimpleXMLElement)#27 (0) {
  }
  [23]=>
  object(SimpleXMLElement)#28 (0) {
  }
  [24]=>
  object(SimpleXMLElement)#29 (0) {
  }
  [25]=>
  object(SimpleXMLElement)#30 (0) {
  }
  [26]=>
  object(SimpleXMLElement)#31 (0) {
  }
  [27]=>
  object(SimpleXMLElement)#32 (0) {
  }
  [28]=>
  object(SimpleXMLElement)#33 (0) {
  }
  [29]=>
  object(SimpleXMLElement)#34 (0) {
  }
  [30]=>
  object(SimpleXMLElement)#35 (0) {
  }
  [31]=>
  object(SimpleXMLElement)#36 (0) {
  }
  [32]=>
  object(SimpleXMLElement)#37 (0) {
  }
  [33]=>
  object(SimpleXMLElement)#38 (0) {
  }
  [34]=>
  object(SimpleXMLElement)#39 (0) {
  }
  [35]=>
  object(SimpleXMLElement)#40 (0) {
  }
  [36]=>
  object(SimpleXMLElement)#41 (0) {
  }
  [37]=>
  object(SimpleXMLElement)#42 (0) {
  }
  [38]=>
  object(SimpleXMLElement)#43 (0) {
  }
  [39]=>
  object(SimpleXMLElement)#44 (0) {
  }
  [40]=>
  object(SimpleXMLElement)#45 (0) {
  }
  [41]=>
  object(SimpleXMLElement)#46 (0) {
  }
  [42]=>
  object(SimpleXMLElement)#47 (0) {
  }
  [43]=>
  object(SimpleXMLElement)#48 (0) {
  }
  [44]=>
  object(SimpleXMLElement)#49 (0) {
  }
  [45]=>
  object(SimpleXMLElement)#50 (0) {
  }
  [46]=>
  object(SimpleXMLElement)#51 (0) {
  }
  [47]=>
  object(SimpleXMLElement)#52 (0) {
  }
  [48]=>
  object(SimpleXMLElement)#53 (0) {
  }
  [49]=>
  object(SimpleXMLElement)#54 (0) {
  }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T19:43:49+00:00Added an answer on June 10, 2026 at 7:43 pm

    just save your complete xml as a string into a session var …

    $_SESSION['theXml'] = $xmlObject->asXML();
    

    and retreive

    $xmlObject = new SimpleXMLElement($_SESSION['theXml']);
    

    Or am I not understanding the question ..?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an object graph that I need to serialize to xml and save
I need to save an object that I have in my program (this object
I define some class as 'DataContract' I need to save this object in my
I need to save all .xml file names in a directory to a vector.
.txt file need save in SD-card. Save(n + String.valueOf(key) + .txt); private void Save(String
I need to save images in certain folder of my application: string path=E:\AJAXEnabledWebSite1\images\gallery I
I need to save an object, its serializable but I donot want to use
I have one application, in that i am using a datarow object like this.
I have a .Net webserivce that accepts XML in string format. XML String sent
i need to save a xml file from a server.. i found a code

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.