Sunday, May 6, 2012

Symfony2 Security component. How to get the user who is logged-in?

If you are using Symfony2(version 2.0.12 2012-03-19 ) and using Security component then you can get the logged in user like this:


$user = $this->container->get('security.context')->getToken()->getUser();

No comments:

Post a Comment