Storing objects in a session PHP 5.2.0



I have read the message boards in this group and others. I still have
not been able to pull my obect out of a session and use it. Here is how
I store it in a session:

<?
//Include the UserClass & RoleClass so that we can create a user
object.
require_once("UserClass.php");
require_once("RoleClass.php");

//This has to be the first line of code a file if sessions are used.
session_start();

//Create a new user object
$user = new User();
$user->setName($_SERVER['HTTP_OBLIX_GIVENNAME']);

$role = new Role();
$role->setSysName($xml->roles[$i]->systemName);
//Now add the role to the user object.
$user->addRole($role);

//Save the user object in the session
$_SESSION['user'] = $user;
?>

This is how I try to pull the object out:

<?
require_once("UserClass.php");
require_once("RoleClass.php");

session_start();

//Include the UserClass & RoleClass so that we can create a user
object.


//See if there is a user object in the session
if ( isset($_SESSION['user']) ){

//Get user object from session
$user = (User)$_SESSION['user'];
}

I have also just tried:
$user = $_SESSION['user'];

?>

I receive errors like these:
<b>Parse error</b>: syntax error, unexpected T_VARIABLE in
<b>/home/as411161/apache/htdocs/common/vcp_menu2.php</b> on line
<b>14</b><br />

.



Relevant Pages

  • Re: how to delete a file that is related to the session object
    ... i have a static object which is created each time the session start: ... this user object is reffered to in my code this way: ... if the application's user closes the window, ... session ends, the garbage collector doesn't always work at that instance. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Business Objects and Session Variables
    ... implementations of patterns here. ... A factory method is one that returns an object to ... each derived from a base user object). ... you can either pull from session or rebuild from the ...
    (microsoft.public.dotnet.framework.aspnet)
  • -forgot- Storing objects in a session PHP 5.2.0
    ... I have read the message boards in this group and others. ... not been able to pull my obect out of a session and use it. ... //Now add the role to the user object. ...
    (comp.lang.php)
  • Re: Business Objects and Session Variables
    ... > returns the user object from userID (or overload, ... > session, but I am not adverse to it either. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: -forgot- Storing objects in a session PHP 5.2.0
    ... not been able to pull my obect out of a session and use it. ... //Include the UserClass & RoleClass so that we can create a user ... //Now add the role to the user object. ...
    (comp.lang.php)