I suppose eraseCredentials
is meant for logout? If so how do I clear session from a Doctrine Entity?
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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With