php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34975 SimpleXML objects can't be stored in sessions.
Submitted: 2005-10-25 02:10 UTC Modified: 2005-10-26 00:43 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: maratd at gmail dot com Assigned:
Status: Not a bug Package: SimpleXML related
PHP Version: 5.0.5 OS: Windows XP
Private report: No CVE-ID: None
 [2005-10-25 02:10 UTC] maratd at gmail dot com
Description:
------------
SimpleXML objects can't be stored in sessions and in turn, objects which contain SimpleXML objects also can't be stored.

Reproduce code:
---------------
<?php

session_start();

$_SESSION['xml'] = simplexml_load_file(YOUR_XML_FILE);

?>

Expected result:
----------------
I expect the simplexml object to be loaded as a session variable, to work, and to persist while the session is active.

Actual result:
--------------
If you first run the code above in a browser on a valid xml file, nothing happens and it looks like it works ... but if you hit refresh or go to a page which re-starts the session, you will see this:

Warning: session_start() [function.session-start]: Node no longer exists in index.php on line 3

The above warning line will repeat over and over for a while ... your simplexml object also won't work.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-10-25 05:12 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

.
 [2005-10-25 05:54 UTC] maratd at gmail dot com
I have checked the manual many times in the past and have done so again. Nowhere does it mention that SimpleXML objects can't be stored as a session variable.

I rewrote the code so that you don't have to create an xml file. Here it is:

<?php 

session_start();

$_SESSION['xml'] = simplexml_load_string('<test><one>two</one></test>');
	
?>

Please run the code provided and restart the session on another page (or hit refresh in your browser). Here is what you will see (the path will obviously be different):

Warning: session_start() [function.session-start]: Node no longer exists in c:\Inetpub\wwwroot\TEMP\test1.php on line 3

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at c:\Inetpub\wwwroot\TEMP\test1.php:3) in c:\Inetpub\wwwroot\TEMP\test1.php on line 3

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at c:\Inetpub\wwwroot\TEMP\test1.php:3) in c:\Inetpub\wwwroot\TEMP\test1.php on line 3

I appreciate any help in this manner. Thank you.

- Marat
 [2005-10-25 08:40 UTC] derick@php.net
It has nothing to do with SimpleXML objects specifically. It's the same for all internal objects - you can't serialize those.
 [2005-10-26 00:43 UTC] maratd at gmail dot com
Thank you very much for the clarification.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 13:01:30 2024 UTC