Javascript

5분전 알림 노출후 30분후 로그아웃 시키기

주원만쉐 2023. 12. 13. 13:56
728x90

// 세션 확인
var intervalSessionCheck = setInterval(function() {
    sessionCheck(0);
}, 1 * 60 * 1000);

function sessionCheck(stat){

    var exp = drms.getCookie("expires");
    var lastRunTime = moment(exp);
    var currentTime = moment();
    var diff = parseInt(moment.duration(currentTime.diff(lastRunTime)).asMinutes());
    var initId = $("#initId").val();
    if (isEmpty(initId) || initId === 'null'){
        goLogin();
    }
    if( stat == 0 && diff >= 25 ){
        clearInterval(intervalSessionCheck);
        setTimeout(function() {
            sessionCheck(1);
        }, 5 * 60 * 1000);
        comm_popup_button('comm_id', '안내', '5분 뒤 로그인 인증이 만료 됩니다.', true, '확인', false, null, goReload);
        $("#baseWrap").css("filter","blur(20px)");
    }
   
    if(stat == 1){
        if( diff < 25 ){
            intervalSessionCheck = setInterval(function() {
                sessionCheck(0);
            }, 1 * 60 * 1000);
        }else{
            comm_popup_button('comm_id', '안내', '로그인 인증이 만료되어 로그인 페이지로 이동 됩니다.', true, '확인', false, null, goLogin);
            $("#baseWrap").css("filter","blur(20px)");
        }
    }
}
728x90