tags:

views:

11

answers:

1

I get one array, when i am parsing a xml file using xpath xquery.The array is this

Array
    (
        [0] => SimpleXMLElement Object
            (
                [userid] => 2
                [username] => UserName
                [userpassword] => 40bd001563085fc35165329ea1ff5c5ecbdbbeef
                [usertype] => A
                [createdBy] => 1
            )

    )

I want to store the userid in a session variale.I created this

if(!empty($nodes))
{
  foreach($nodes as $node)
  {
   $UserId=$node->userid;
  }
}
$_SESSION['UserId1']= $UserId; 

Inside the foreach the session is getting.But if i run the page again am getting

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

and the session is not getting.Can anybody give a solution

+1  A: 

You tried to store the reference to a node from your SimpleXML object. But you have to store the content of this node instead. To do this, simply cast it to a string:

$UserId = (string)$node->userid;
Kau-Boy
I have used session_start()
THOmas
Sorry, I misread the warning. See my edit for the real issue.
Kau-Boy
Thanks Kau-Boy . it is working fine
THOmas