Solve PHP Warning : session_start() [function.session-start]: Node no longer exists

PHP Warning : session_start() [function.session-start]: Node no longer exists

This error is really annoying and can be hard to solve, it appears in two forms and only after a session has already been set.
This error will output two different messages :

Solution is really simple, you have a SimpleXMLElement in your $_SESSION that does not deserialize properly.

Finding what variable trigger the error

PHP only tells you where the error kicks in (the session_start()), not where it really happened. To verify the diagnostic, first find your session.save_path

In PHP

or simply

On your server

Then go to this directory and open a sess_XXX file, then find a string looking like

In serialized code, it means your variable myVariable is an Object, whose class name is 16 characters long and is SimpleXMLElement, 0:{} means it’s empty.

Fixing the error

You need then to add a string cast in your PHP script for this variable when you assign it to the $_SESSION

If you have a more complex SimpleXMLElement (eg : a XML node, not just a string), then use the asXML() method

Don’t forget to change your access to this session variable as it will not be a SimpleXMLElement but rather a string containing XML.

Leave a Reply

Your email address will not be published. Required fields are marked *