参考:http://laravelacademy.org/post/7954.html
一、存session
DB::table('manager')->where(['id'=> $data->id])->update(['end_login_time' => $time, 'end_login_ip' => $ip]);
session(['user'=>$data]);//存入
二、删除session /退出登录
php:
public function logout(Request $request)
{
if(!empty($request->get("a"))){
session()->forget('user');
session()->flush();//移除所有
return json_encode(['msg'=>"ok",'code'=>1]);
}
return view('team.logout');
}
js:
(function(){
var wait = document.getElementById('wait'),
href = document.getElementById('href').href;
var interval =setInterval(function(){
var time = --wait.innerHTML;
if(time <=0) {
var _href="/logout?a=1";
$.ajax({
url: _href,
type:"get",
success:function (info) {
location.href = href;
clearInterval(interval);
}
});
};
}, 1000);
})();
html:
网友评论