Using javascript for pinging a webapp to keep session open

前端 未结 6 716
一个人的身影
一个人的身影 2021-01-31 10:26

I\'m writing a greasemonkey script to keep session open on a webapp I use for work. Which javascript command would you use to create some feedback with the server and ensure the

6条回答
  •  鱼传尺愫
    2021-01-31 10:48

    I've solved the issue using:

    function keepAlive() {
        var httpRequest = new XMLHttpRequest();
        httpRequest.open('GET', "/restricted_file_url");
        httpRequest.send(null);
    }
    
    setInterval(keepAlive, 840000);  //My session expires at 15 minutes
    

提交回复
热议问题