php 取消页面缓存,php – 如何删除特定页面的缓存

调用注销功能时销毁会话.只需在控制器中编写注销功能,如下所示:

public function getLogout() {

Sentry::logout();

Session::flush(); // Insert this line, it will remove all the session data

return Redirect::to('users/login')->with('message', 'Your are now logged out!');

}

编辑:

首先我只使用Session:flush(),并且它以某种方式工作!但是当我再次检查时,我发现它无法正常工作.因此,我们需要在注销时添加更多代码以清除浏览器缓存.

使用过滤器可以解决此问题. (我还没有找到任何其他解决方案)首先,在filters.php中添加此代码:

Route::filter('no-cache',function($route, $request, $response){

$response->header("Cache-Control","no-cache,no-store, must-revalidate");

$response->header("Pragma", "no-cache"); //HTTP 1.0

$response->header("Expires"," Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past

});

然后将此过滤器附加到路由或控制器.我将它附加到控制器的构造函数中,如下所示:

public function __construct() {

$this->beforeFilter('csrf',array('on' => 'post'));

$this->afterFilter("no-cache", ["only"=>"getDashboard"]);

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值