rashidkhan
rashidkhan

Reputation: 472

Symofony 3.3 How to force user log out?

I have given the users the option to delete themselves from a company and after that I have to deactivate their account and force them logout. But if the rememerme cookie is set, the user it not logged out, no matter what. This is the code I am using to force logout the user.

        $this->get("security.token_storage")->setToken(null);
        $this->get("session")->invalidate(true);

        $targetUrl = $this->generateUrl("logout");

and then I send a response with that logout url. How can I unset the rememberme cookie, note: I have multiple rememberme cookies for different systems inside the main system.

Thanks.

Upvotes: 1

Views: 55

Answers (1)

ThomasVdBerge
ThomasVdBerge

Reputation: 8140

You could try removing the cookie.

Something like this:

unset($_COOKIE['remember_user']);
setcookie('remember_user', null, -1, '/');

Upvotes: 1

Related Questions