Posted by Anthony Smith on 11/27/06 15:22
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 />
I also get this message:
<b>Warning</b>: session_start() [<a
href='function.session-start'>function.session-start</a>]: Node no
longer exists in
<b>/home/as411161/apache/htdocs/common/vcp_menu2.php</b> on line
<b>5</b><br />
Navigation:
[Reply to this message]
|