[thelist] [PHP Newbie] Accessing Object attributes from a _SESSION variable
Jacques Capesius
jacques_capesius at cnt.com
Wed Oct 29 12:06:02 CST 2003
Hi folks,
I'm starting to dabble in some PHP and have run into a real stumper (at
least for me).
I have a PHP class, person, that looks like this:
class person {
// set up the object
var $firstname;
var $lastname;
var $email;
var $username;
var $password;
var $loggedin;
var $group;
// plus various methods...
}
Upon successful login, I load the attributes with their respective values
and load the variable of type person into a session variable via the
following code:
$_SESSION["person"] = $person; // person is the variable.
I then forward to a different page and try to read from the session with the
following code:
print_r($_SESSION);
echo "<br>firstname: ".$_SESSION["person"]->firstname."<br>";
the output is:
Array
(
[person] => __PHP_Incomplete_Class Object
(
[__PHP_Incomplete_Class_Name] => person
[firstname] => Jacques
[lastname] => Capesius
[email] => jacques_capesius at cnt.com
[username] => jcapesius
[password] =>
[loggedin] => 1
[group] => ibm
)
)
<br>firstname: <br>
Obviously, the second line of code above isn't working. My question is, how
to I refer to the attribute values of an object I have stored in a session
variable?
thanks for any help you can offer.
-jacques :)
More information about the thelist
mailing list