I have a laravel project where when I logout from the user I go to the login screen, but when going back to the previous page in browser I can acces the home page even if I have logged out. How can I fix it?
AuthController.php
public function logout()
{
\Auth::logout();
\Session::flush();
return redirect()->route('login');
}
}
UsersController.php (the home function that returns the home view)
public function home()
{
if (\Auth::user())
{
return view('users.home');
}
return redirect()->route('login');
}
web.php (the route)
Route::get('/home', ['middleware' => 'auth', 'as' => 'home','uses' => 'UsersController@home']);