#34975 [Opn->Bgs]: SimpleXML objects can't be stored in sessions.

From: Date: Tue, 25 Oct 2005 06:40:13 +0000
Subject: #34975 [Opn->Bgs]: SimpleXML objects can't be stored in sessions.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-87012@lists.php.net to get a copy of this message
ID: 34975 Updated by: derick@php.net Reported By: maratd at gmail dot com -Status: Open +Status: Bogus Bug Type: SimpleXML related Operating System: Windows XP PHP Version: 5.0.5 New Comment: It has nothing to do with SimpleXML objects specifically. It's the same for all internal objects - you can't serialize those. Previous Comments: ------------------------------------------------------------------------ [2005-10-25 05:54:13] 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 05:12:27] 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 02:10:58] 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. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=34975&edit=1

« previous php.bugs (#87012) next »