-1

Laravel 5.2 closes the session, but when I press the return of the browser shows me the previous view in AutenticatesUsers is the following and it works but if I access and I pass through several modules and then I close the session and I return? Twice then the first one remains in the login and the second one shows me the previous module with username and everything .. only if the surcharge sends me to login. As it is because of the browser cache, but what could I do so that it does not return or enter the pages that way ??

public function logout(Request $request) {
  Auth::guard($this->getGuard())->logout();
  $request->session()->flush();
  Auth::logout();
 return redirect(\URL::previous());

 return redirect(property_exists($this, 'redirectAfterLogout') ? $this->redirectAfterLogout : '/');

1 Answers1

0

Your method looks quite complex if it's just meant to logout a user, and why are there two return statements? I had a hard time understanding your question so correct me if i'm wrong, but as far as i could understand Laravel is not clearing the Sessions properly for you.

I believe this is an issue that's already been covered here: Laravel - session data survives log-out/log-in, even for different users

Also try to clear the session using Session::flush(), you shouldn't require Auth::logout if you're already flushing the entire Session also, if you're using HTTP Basic Auth know that it does not support logging out, you'll stay logged in until the browser is closed.

Community
  • 1
  • 1
JonnySerra
  • 1,044
  • 3
  • 13
  • 27