Laravel logout fail on pressing back button

前端 未结 5 1994
孤独总比滥情好
孤独总比滥情好 2021-01-06 18:17

On logout from my Laravel application using the Laravel logout method:

public function getLogout() 
    {
       Auth::logout();
       return Redirect::to(\         


        
5条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-06 18:56

    I tried with this and it works.

    In routes:

    Route::group(array('before' => 'auth', 'after' => 'no-cache'), function()
    {
    Route::get('dashboard', array('as' => 'getDashboard', 'uses' => 'DashboardController@getIndex'));
    
    Route::get('logout', array('as' => 'getLogout', 'uses' => 'LoginController@getLogout'));
    
    Route::group(array('prefix' => 'users'), function()
    {
        Route::get('users', array('as' => 'getUsers', 'uses' => 'UsersController@getIndex', 'before' => 'hasAccess:users.index'));
    });
    });
    

    In filters:

    Route::filter('no-cache',function($route, $request, $response){
    
    $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');
    
    });
    

提交回复
热议问题