membuat lougout tidak bisa di back di laravel
pertama...
buat middleware
di sini saya buat NoCache Middleware...
>>php artisan make:middleware NoCacheMiddleware
tambah kan fungsi seperti di bawah
>>
public function handle($request, Closure $next)
{
$response = $next($request);
$response->headers->set('Cache-Control','nocache, no-store, max-age=0, must-revalidate');
$response->headers->set('Pragma','no-cache');
$response->headers->set('Expires','Fri, 01 Jan 1990 00:00:00 GMT');
return $response;
}
jika sudah ke tahap 2..
register middleware yg tadi di buat ke kernel.php
'nocache'=>\App\Http\Middleware\NoCacheMiddleware::class,
];
nocache adalah nama/alias midlleware yg saya buat.. (bebas namanya tdak sama dengan middleware juga ga papa)..
yg terakhir masukan middleware ke routes..
>>Route::group(['middleware' => ['web','auth','nocache']], function () {
simpan semua route di sini yg udah login
});
buat middleware
di sini saya buat NoCache Middleware...
>>php artisan make:middleware NoCacheMiddleware
tambah kan fungsi seperti di bawah
>>
public function handle($request, Closure $next)
{
$response = $next($request);
$response->headers->set('Cache-Control','nocache, no-store, max-age=0, must-revalidate');
$response->headers->set('Pragma','no-cache');
$response->headers->set('Expires','Fri, 01 Jan 1990 00:00:00 GMT');
return $response;
}
jika sudah ke tahap 2..
register middleware yg tadi di buat ke kernel.php
'nocache'=>\App\Http\Middleware\NoCacheMiddleware::class,
];
nocache adalah nama/alias midlleware yg saya buat.. (bebas namanya tdak sama dengan middleware juga ga papa)..
yg terakhir masukan middleware ke routes..
>>Route::group(['middleware' => ['web','auth','nocache']], function () {
simpan semua route di sini yg udah login
});
0 comments: