I was just working on some PHP and encountered a problem where my session was lost after doing a header redirect. After googling and doing some read up, I realised that the problem lies with using simplexml with the session variables:
For example:
$name = $simplexml -> table[0] -> name
$_SESSION["name"] = $name;
if you attempt to do a header redirect thereafter: header(”anotherpage.php”); , and try to access the session variable in anotherpage.php like
echo $_SESSION["name"];
Then an error might occur which says “Warning: session_start() [function.session-start]: Node no longer exists in …”
The solution to this problem is simple, simply cast the $name above to (string)$name so it looks like:
$name = $simplexml -> table[0] -> name
$_SESSION["name"] = (string)$name;





Recent Comments