하나의 thing.i를 구현하고 싶습니다. 여러 탭에서 내 사이트를 열었습니다. 한 탭에서 작업하는 동안 다른 탭은 타임 아웃되지 않아야합니다. 살아 있어야합니다. 다른 탭을 유지하는 법. 나는 유휴 시간 로그 아웃을 찾기 위해 js 이하를 사용했다.같은 브라우저에서 여러 탭을 열어도 세션을 활성 상태로 유지하는 방법
<script type="text/javascript">
idleTime = 0;
$(document).ready(function() {
//Increment the idle time counter every minute.
var idleInterval = setInterval("timerIncrement()", 60000); // 1 minute
//Zero the idle timer on mouse movement.
$(this).mousemove(function (e) {
idleTime = 0;
});
$(this).keypress(function (e) {
idleTime = 0;
});
})
function timerIncrement() {
idleTime = idleTime + 1;
if (idleTime > 2) { // 30 minutes
var beforeTime = new Date()
var bminutes = beforeTime.getMinutes();
var bseconds = beforeTime.getSeconds();
var user='<?php echo Auth::getSessionUserFullName();?>';
if(user!='')
{
var timehours=beforeTime.getHours();
var timeoutmin=bminutes+1;
var timeoutseconds=bseconds-1;
if(timeoutseconds>59)
{
timeoutseconds=0;
timeoutmin=timeoutmin+1;
}
if(timeoutmin>59)
{
timeoutmin=0;
timehours=hours+1;
}
if(timehours>24)
{
timehours=0;
}
var ok=confirm("Your session expire time started at "+beforeTime.getHours()+":"+beforeTime.getMinutes()+":"+beforeTime.getSeconds()+".Please click 'OK' before "+timehours+":"+timeoutmin+":"+timeoutseconds+" to stay signed in.");
if(ok)
{
var currentTime = new Date()
var aminutes = currentTime.getMinutes();
var aseconds = currentTime.getSeconds();
var time=aminutes-bminutes;
if(aminutes>bminutes && aseconds>bseconds)
{
alert('Time out!!Please login again to access.');
window.location.href='<? echo APPLICATION_WEBROOT?>auth/logout';
return false;
}
else if(time>=2)
{
alert('Time out!!Please login again to access.');
window.location.href='<? echo APPLICATION_WEBROOT?>auth/logout';
return false;
}
else
{
return true;
}
}
else
{
window.location.href='<? echo APPLICATION_WEBROOT?>auth/logout';
}
}
}
}
</script>
도와주세요. 열려있는 모든 탭에 대한 세션을 유지하는 방법 사전에 축하합니다.
에서 세션을 유지하기 위해 가능한 방법이 될해야하지만
은 내가하지 않은 많은 일을있을 수 있습니다 당신은 단순히 할 수 없습니다. 브라우저 탭은 다른 브라우저 탭에 대해 알지 못합니다. – Jon
확인. js를 제거하는 동안 어떻게 구현할 수 있습니다. – Krishna38