PHP: Catchable fatal error: Object of class DOMElement could not be converted to stri

Im trying to create an XML file from the input of a form. It works fine. But then, I wanted to add to the file data from session variables. It’s something like this:


$stat = $doc->createElement('status');
$root->appendChild($stat);
$stext = $doc->createTextNode($_POST['status']);
$stat->appendChild($stext);

$useridConversion = $_SESSION['userid'];
settype( $useridConversion, 'string');

$userid = $doc->createElement('userid');
$root->appendChild($userid);
$useridtext = $doc->createTextNode($useridConversion);
$userid->appendChild($useridtext);

The status part works very well, but when I want to add information from a $_SESSION variable it gives me that error. I did the conversion because it wouldn’t let me do it straight from the $_SESSION variable so then I try to convert it to a string and it doesnt work either.

Any suggestions?

Thanks in advance,

Leo