CakePHP 3: How to properly check if a user is logged in
I think the best way is just:
if ($this->Auth->user()) {...}
You can do this using session()
helper.
$loggeduser = $this->request->session()->read('Auth.User');
if(!$loggeduser) {
$userID = $loggeduser['id'];
$firstName = $loggeduser['first_name'];
}