【问题标题】:Ext js client request for session active springExt js客户端请求会话活动弹簧
【发布时间】:2014-05-19 16:59:15
【问题描述】:
我需要检查会话在我的客户端是否仍然处于活动状态。是否有任何可能不会延长会话的请求?然后我可以使用此请求来检查会话是否仍处于活动状态。请提供建议,我不知道如何克服这个问题。
【问题讨论】:
标签:
session
extjs
spring-security
【解决方案1】:
您可以使用 setInterval 函数和 ExtJS Ajax 请求来检查您指定时间的活动会话。
var checkSession = Ext.Ajax.request({
// the following url must response a value based on the
// user session status, long story short
// you should define a function in Grails
url: '/grails_url/function',
method: 'POST',
success: function (response) {
Ext.Msg.show({
title: 'Session Expired...',
msg: 'You session has been expired!',
width: 300,
height: 200,
closable: false,
buttons: Ext.Msg.INFO,
buttonText: { ok: 'OK'},
icon: Ext.Msg.INFO,
fn: function(btn) {
if (btn == 'ok') {
window.location.href = 'http://www.domain.com/login';
}
}
})
}
});
// check session for every 5 sec
setInterval(checkSession, 5000);