I wrote a class to handle user authentication and session variable creation for an enterprise-scale web app.
In a nutshell, once the user is authenticated, we pull their metadata out of the MySQL db and assign each field as an object of the class....
something like this:
$user->email = $row->email_address;
Next, I use another method to assign these objects to session variables, like:
$_SESSION[email] = $user->email;
The problem I'm having is that when trying to access the session vars in the method of another class, I am getting this error:
So, attempting something like this in a class called "email"...
$from = "FROM: " . $_SESSION[email] . "\r\n";
...results in this....
Catchable fatal error: Object of class __PHP_incomplete_class could not be converted to string in ...
So, what I'm thinking is that in my user class, when I assign the user objects to session vars, I need to invoke the __toString() function for each.
My question here is how do I write a __toString() function to handle multiple variables? The ONLY examples I've seen online return only one value, like this:
public function __toString() {
return $this->content;
}
I guess the simplest thing to do would be to assign the query objects directly to session vars instead of first assigning them to class objects. I'd rather get it working correctly though.