in cakephp 3, found 2 ways find if user logged in.
1st solution
if(!is_null($this->auth->user('id'))){ // logged in } 2nd solution
if (!is_null($this->request->session()->read('auth.user.id'))) { // logged in } i think first 1 better because it's short , concise.
is there better way verify if user logged in?
i'm not looking speed necessarily. want clean , expressive way write it.
i think best way just:
if ($this->auth->user()) {...}
Comments
Post a Comment