首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >我们可以在Coldfusion中恢复会话吗?

我们可以在Coldfusion中恢复会话吗?
EN

Stack Overflow用户
提问于 2011-04-26 03:41:00
回答 5查看 1.5K关注 0票数 2

我在会话中存储了5-6个变量值。当我的会话结构即将到期时,我该如何续订它?我正在使用Coldfusion 8。谢谢!

EN

回答 5

Stack Overflow用户

回答已采纳

发布于 2011-04-26 03:43:22

使用AJAX ping服务器以保持会话处于活动状态

或者只是简单地延长会话超时timeSpand。

票数 6
EN

Stack Overflow用户

发布于 2011-04-26 04:46:13

从该会话对CFM页面的任何调用都会导致该会话被延长。我所看到的是一个JS计时器将会运行,并在会话到期之前不久结束。当计时器超时时,它会触发一个弹出窗口,该弹出窗口加载一个非CFM页面(Basic HTML),该页面会显示一条关于会话即将结束的消息,并询问用户是否要继续该会话。

票数 2
EN

Stack Overflow用户

发布于 2016-06-22 03:11:36

下面是自动ping服务器的Ajax的概念(如Henry's answer中所建议的)。

代码语言:javascript
运行
复制
//This function will keep the session alive as long as the page is still open.
//Whenever the page nears expiration, it automatically extends it. 
function autoExtendSession(days,hours,mins,secs){
    var milliseconds = (days*86400000)+(hours*3600000)+(mins*60000)+(secs*1000);
    setTimeout(
    function(){
        $.post("server/heartbeat.cfm");
        console.log("Heartbeat sent to the server.");

        //Start another timer.
        autoExtendSession(days,hours,mins,secs)

    //Once we are 98% of the way to the timeout, the heartbeat is sent.
    //This way the timeout should never actually be reached.
    }, milliseconds-(milliseconds*0.02));
};

hearbeat.cfm页面实际上不必包含任何内容,当$.post访问它时,服务器将续订会话,无论它是否包含内容。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5782420

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档