how to find out my current user id in other page controller after i login?

后端 未结 5 538
离开以前
离开以前 2021-02-06 12:30

i am planing to set a permission on my event index page, which just allow certain user to view which had set when i add the event. After user click into my event, the event cont

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-06 12:50

    The recommended approach for getting logged in user data is via the AuthComponent itself:

    // in any controller
    $userId = $this->Auth->user('id');
    

    See Accessing the logged in user in the Auth section of the CakePHP Book.

提交回复
热议问题