1

After trying a lot of different ways (success handler, cache directives, changing routes, overriding methods, etc.) I haven't been able to logout a user (using the FOSUserBundle) disabling her to see previous pages when pressing the back-button of the browser.

Is there a way to do it in Symfony 2.6?

In CakePHP this works perfectly in a Controller

public function logout() {

    session_destroy();
    $this->Auth->deny('*');
    $this->Auth->shutdown('*');
    $this->Session->setFlash('Logout succesful - no back button issue.');
    return $this->redirect($this->Auth->logout());

}
Calamar
  • 1,378
  • 1
  • 11
  • 21

3 Answers3

1

Add the following headers to the top of the page in your application:

 header("Cache-Control: no-cache, no-store, must-revalidate"); 
 header("Pragma: no-cache");
 header("Expires: 0");
Dean Meehan
  • 2,391
  • 19
  • 34
A_S
  • 107
  • 7
0

You can redirect to logout page:

return $this->redirectToRoute('fos_user_security_logout');
Aistis
  • 3,332
  • 2
  • 32
  • 32
0

You need to send no-cache directive to the browser Try this solution https://stackoverflow.com/a/41566590/1154919

Community
  • 1
  • 1
Yuriy Yakubskiy
  • 429
  • 5
  • 6