在Laravel中如何自动注销会话?我已经在session.php中添加了这个
SELECT a.ClientName, b.AttendedBy
FROM TableA A
JOIN TableB b ON a.ClientId = b.ClientId
WHERE a.ClientId IN (SELECT DISTINCT ClientId FROM Table B WHERE AttendedBy = 'Peter')
答案 0 :(得分:1)
使用JS处理-(在我的项目中可以正常工作)
/*
* this script is for manage the logout of timeout
* if user is inactive for 15 min
* he will be logout :
*
* */
var logout = 'Are you sure to logout?';
var timeout;
var url = ''; // route path;
document.onmousemove = function(){
clearTimeout(timeout);
timeout = setTimeout(function () {
var confirmstatus = confirm( logout );
if(confirmstatus === true) {
var redirect = $.ajax({
cache: false,
url: url,
type: "GET",
headers: {
'X-CSRF-TOKEN': window.project.csrfToken
},
contentType: false,
processData: false,
success: function (response) {
window.location.href = url;
}
});
}
}, 60000*15);
};
</script>
答案 1 :(得分:0)
您应该尝试以下解决方案。
Use Auth;
public function logout(Request $request) {
Auth::logout();
return redirect('/login');
}