这是我的路线.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('');
}
一旦我注销,我就会成功重定向到''
页面,即本地主机/主页,因为我的登录控制器中有这个
public function home()
{
return View::make('login/home');
}
我的问题是,一旦我按下注销并按下后退按钮,我就能看到本地主机/主页,尽管我已经在Route::group(array('before' => 'auth'), function()
内使用了它
我还配置了过滤器.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');
}
}
});
注意:一旦我刷新它就会定向注销,但我什至不想在他们刷新之前显示主页
注销后,如何防止从浏览器按后退按钮后显示主屏幕?
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