Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony 2 Logout (UserInterface::eraseCredentials)

I suppose eraseCredentials is meant for logout? If so how do I clear session from a Doctrine Entity?

like image 403
Jiew Meng Avatar asked Dec 10 '11 08:12

Jiew Meng


1 Answers

No, eraseCredentials() is meant for erasing sensitive data before persisting a token — be it serialization or a database.

To logout a user programmatically, you can use this:

$this->get('security.context')->setToken(null);
$this->get('request')->getSession()->invalidate();
like image 70
Elnur Abdurrakhimov Avatar answered Oct 15 '22 14:10

Elnur Abdurrakhimov