Getting the User (Identity) - CakePHP4
Getting the User (Identity) - CakePHP4
Method 1 - Preferred:
$user = $this->Authentication->getIdentity(); debug($user['id']);exit;
Getting from Session:
$user = $this->getRequest()->getSession()->read('Auth');
debug($user->id);exit;
Getting Fields from Session:
$userId = $this->getRequest()->getSession()->read('Auth')->id;