Prevent Browser's Back Button Login After Logout in Laravel 5

前端 未结 8 814
情歌与酒
情歌与酒 2020-12-01 02:50

I am new to Laravel 5 and trying to make a simple authentication page. My problem is i can logout properly after i click to logout link but if i click to back button of the

8条回答
  •  生来不讨喜
    2020-12-01 03:30

    Step 1 : create one middleware using following command:

    php artisan make:middleware PreventBackHistory
    

    Step 2:

    replace content of PreventBackHistory.php with following content:

    header('Cache-Control','no-cache, no-store, max-age=0, must-revalidate')
                ->header('Pragma','no-cache')
                ->header('Expires','Sun, 02 Jan 1990 00:00:00 GMT');
        }
    }
    

    step 3: register middleware in kernal.php

    'preventBackHistory' => \App\Http\Middleware\PreventBackHistory::class,
    

    And good to go :)

提交回复
热议问题