Node no longer exists error with Zend_Session

Hi, I have problems with my sessions using Zend Framework 1.7.6.

The problem occurs when I try to store an array in a session, the session namespace also stores other user data.

I am currently receiving the following message on my stack

 Fatal error: Uncaught exception 'Zend_Session_Exception' with message 'Zend_Session :: start () - 
 ...

 Error # 2 session_start () [function.session-start]: Node no longer exists Array 

Code where I think this is an error:

//now we add the user object to the session $usersession = new Zend_Session_Namespace('userdata'); $usersession->user = $user; //we now get the users menu map $menuMap = $this->processMenuMap($menuMapPath); $usersession->menus = $menuMap; 

This error appeared only after trying to add an array to the session namespace.

Any ideas that Node might trigger are no longer an Array message ?

Many thanks

+1
php session zend-framework
source share
2 answers

Are you trying to save a SimpleXML object or something else libxml related to session data?
This does not work because the underlying DOM tree is not restored when objects are unesterified during session_start() . Instead, store the XML document (as a string).

You can achieve this, for example. by providing "magic functions" __sleep() and __wakeup() . But __sleep() should return an array with the names of all the properties that should be serialized. If you add another property, you will also have to modify this array. This removes some of the machines ...

But if your menumap class has only a few properties, this may be possible for you.

 <?php class MenuMap { protected $simplexml = null; protected $xmlstring = null; public function __construct(SimpleXMLElement $x) { $this->simplexml = $x; } public function __sleep() { $this->xmlstring = $this->simplexml->asXML(); return array('xmlstring'); } public function __wakeup() { $this->simplexml = new SimpleXMLElement($this->xmlstring); $this->xmlstring = null; } // ... } 
+3
source share

You must save the XML string in the session. Alternatively, you can create a wrapper class around this XML line, which:

In these methods, you can take care of the state of the object.

+1
source share

All Articles