如何在注销后阻止显示主页

时间:2015-01-28 01:48:52

标签: php authentication laravel laravel-4 laravel-routing

这是我的 routes.php

<?php
#HomePage
Route::get('/', 'LoginController@home');
Route::post('login', 'LoginController@Login');
Route::group(array('before' => 'auth'), function()
{
Route::get('home', 'HomeController@HomeLayout');
Route::get('logout', 'LoginController@Logout');
});

退出时我有

   public function Logout()
    {
        Session::flush();
        return Redirect::to('');
    }

一旦我注销,我就成功重定向到''页面,即 localhost / home ,因为我在登录控制器中有这个

public function home()
{
    return View::make('login/home');
}

我的问题是我按下退出后按下后退按钮我可以看到localhost / home虽然我在Route::group(array('before' => 'auth'), function()

中使用了它

我还配置了 filters.php

Route::filter('guest', function()
{
    if (Auth::check()) return Redirect::to('/')->with('Message', 'Please Login to get Access');
});

Route::filter('auth', function()
{
    if (Auth::guest())
    {
        if (Request::ajax())
        {
            return Response::make('Unauthorized', 401);
        }
        else
        {
            return Redirect::guest('')->with('Message', 'Please Login to get Access');
        }
    }
});

注意:一旦刷新它会指示退出,但我甚至不想在刷新之前显示主页

如果我们退出后从浏览器按回按钮后,如何阻止显示主屏幕?

1 个答案:

答案 0 :(得分:1)

App::after(function($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');
});

routes.php中添加这些行并检查。

这将清除cache