CakePHP check if user is logged in inside a view

前端 未结 12 1924
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-24 13:00

I have the following code:

    Auth->user())
    {
        echo $this->element(\'header\');
    }
    else
    {
        e         


        
12条回答
  •  春和景丽
    2020-12-24 13:37

    You don't need to do $this->set(compact('authUser')); only use this in View:

    if ($this->Session->read('Auth.User')){
    // do something 
    }
    

提交回复
热议问题