Symfony 2 Logout (UserInterface::eraseCredentials)

前端 未结 2 521
梦如初夏
梦如初夏 2020-12-30 08:21

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

2条回答
  •  难免孤独
    2020-12-30 08:57

    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();
    

提交回复
热议问题