CakePHP check if user is logged in inside a view

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

I have the following code:

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


        
12条回答
  •  没有蜡笔的小新
    2020-12-24 13:34

    in cakephp 3 you can check authentication session in the view like this

    if($this->request->Session()->read('Auth.User')){
    //do when login
    }
    else{
     //do not login
    }
    

提交回复
热议问题