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,547
  • 1
  • 13
  • 25

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,511
  • 22
  • 36
A_S
  • 127
  • 7
0

You can redirect to logout page:

return $this->redirectToRoute('fos_user_security_logout');
Aistis
  • 3,695
  • 2
  • 34
  • 34
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
  • 539
  • 5
  • 6