On logout from my Laravel application using the Laravel logout method:
public function getLogout()
{
Auth::logout();
return Redirect::to(\
Since I am new in Laravel. So in Laravel 5.7 I fixed that problem in my way. Create a middleware using artisan.
php artisan make:middleware RevalidateBackHistory
Within RevalidateBackHistory middleware, we set the header to no-cache and revalidate.
header('Cache-Control','nocache, no-store, max-age=0, must-revalidate')
->header('Pragma','no-cache')
->header('Expires','Fri, 01 Jan 1990 00:00:00 GMT');
}
}
Update the application’s route middleware in Kernel.php
protected $routeMiddleware = [
.
.
'revalidate' => \App\Http\Middleware\RevalidateBackHistory::class,
.
.
];
Update the route in Web.php. In my case.
Route::group(['middleware' => 'revalidate'], function(){
Route::get('/', 'HomeController@index');
Route::get('/home', 'HomeController@index');
Route::get('/dashboard', 'HomeController@index');
});
And that’s all! So basically you just need to call revalidate middleware for routes which require user authentication.
Here is the url's I followed
Prevent Browser's Back Button Login After Logout in Laravel 5
https://www.youtube.com/watch?v=wLkA1g2s65U