have to logout the particular user should be logged out after 15 minutes of inactivity

Existing code:

function Inactivitytime(){
     console.log(1);
     let time;
     window.onload = resetTimer;
     document.onmousemove = resetTimer;
     document.onkeypress = resetTimer;

     function logout() {
         var root = document.location.origin;
         document.cookie = emp_id +'='+ empid +'; Path=/;';
         document.cookie = emp_email +'='+ emp_email +'; Path=/;';
         document.cookie = empname +'='+ emp_name +'; Path=/;';
         setCookie('emp_id','',time()-3600)
         setCookie('emp_email','',time()-3600)
         setCookie('empname','',time()-3600) 
         window.location.href = root+"/index.php";
         console.log(2);
    }

    function resetTimer() {
        clearTimeout(time);
        time = setTimeout(logout, 4000)
        console.log(3);
    }
}

Tried implementation

 document.cookie = emp_id +'='+ empid +'; Path=/;';
 document.cookie = emp_email +'='+ emp_email +'; Path=/;';
 document.cookie = empname +'='+ emp_name +'; Path=/;';
 setCookie('emp_id','',time()-3600)
 setCookie('emp_email','',time()-3600)
 setCookie('empname','',time()-3600) 

i have tried this don’t have any isue with code but the only problem is it’s not getting signed out
suggest me any changes THanks in advance!!!