使用JavaScript ping Web应用程序以保持会话打开 [英] Using javascript for pinging a webapp to keep session open

查看:33
本文介绍了使用JavaScript ping Web应用程序以保持会话打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个油脂猴子脚本,以使会话在我用于工作的Web应用程序上保持打开状态. 您将使用哪个javascript命令与服务器创建一些反馈,并确保会话不会落在不必打扰用户完全刷新页面的情况下?

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 session doesn't fall without having to bother the user making a complete refresh of the page?

推荐答案

我已使用以下方法解决了该问题:

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

这篇关于使用JavaScript ping Web应用程序以保持会话打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆