Symfony getting logged in user's id

后端 未结 5 684
独厮守ぢ
独厮守ぢ 2020-12-05 09:35

I am developing an application using Symfony2 and doctrine 2. I would like to know how can I get the currently logged in user\'s Id.

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-05 09:46

    In symfony2, we can get this simpler by this code:

    $id = $this->getUser()->getId();
    

提交回复
热议问题