Create a middleware named PreventBackHistory
and add the below lines.
<?php
namespace App\Http\Middleware;
use Closure;
class PreventBackHistory
{
public function handle($request, Closure $next)
{
$response = $next($request);
return $response->header('Cache-Control','nocache, no-store, max-age=0, must-revalidate')
->header('Pragma','no-cache')
->header('Expires','Sun, 02 Jan 1990 00:00:00 GMT');
}
}
Now Open the kernal.php.
Find protected $routeMiddleware and add below line.
'prevent-back-history' => \App\Http\Middleware\PreventBackHistory::class,
In your route.php file write these lines.
Route::group(['middleware' => 'prevent-back-history'],function()
{
*********** Write your route files here. example************
Route::get('/home', 'HomeController@index')->name('home');
});
and add the below lines.
<?php
namespace App\Http\Middleware;
use Closure;
class PreventBackHistory
{
public function handle($request, Closure $next)
{
$response = $next($request);
return $response->header('Cache-Control','nocache, no-store, max-age=0, must-revalidate')
->header('Pragma','no-cache')
->header('Expires','Sun, 02 Jan 1990 00:00:00 GMT');
}
}
Now Open the kernal.php.
Find protected $routeMiddleware and add below line.
'prevent-back-history' => \App\Http\Middleware\PreventBackHistory::class,
In your route.php file write these lines.
Route::group(['middleware' => 'prevent-back-history'],function()
{
*********** Write your route files here. example************
Route::get('/home', 'HomeController@index')->name('home');
});