I have a User
class which is created when a user logs in
$user = new User($userId);
Now to check if a user is logged in, I tried doing
if (isset($user)) { // user is logged in
} else { // user is not logged in
}
However, isset()
doesn't appear to work for objects? And I've also tried is_object()
. Please advise! Hopefully there is a way to do this elegantly, perhaps
if ($user->isLoggedIn()) {
}
Thanks for your time!