I'm trying to apply a logout in my laravel 5.5 project with this method:
Route::get('/logout', function () {
Auth::logout();
return redirect('login');
})->name('auth_logout');
But when I click on the back of the browser, it returns me to the previous page it was in and the user is still authenticated when the session should have been deleted.
I have created a middleware to deal with this:
public function handle($request, Closure $next)
{
header('Last-Modified:'.gmdate('D, d M Y H:i:s').'GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0',false);
header('Pragma: no-cache');
return $next($request);
}
This middleware works for me; but I feel that this method is not effective at all because if we click several times in the back there comes a time when it returns to the previous page and the user remains authenticated.
There will be some way to delete the session in laravel when I run the logout()
to automatically redirect to the login. Reviewing the method logout()
of Auth
this is empty.
Sldos