What is the sfUser equivalent in Symfony 2?
sfUser allowed getting user session attributes using getAttribute() method.
Is Symfony\Component\Security\Core\User\User its equivalent? But it doesn’t have getAttribute() method in it.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To get session attributes, get the session service from the container. This example is in a controller, where the session is available via a helper method:
See the documentation for details. You can also retrieve the session explicitly from the container should you need it, via
$container->get("session");If you need the User object, you can get it via:
Again, see the documentation for further details.