Ext js客户端请求会话活动spring

时间:2014-04-07 12:36:42

标签: session extjs spring-security

我需要检查会话在我的客户端是否仍处于活动状态。是否有任何可能不会延长会话的请求?我可以使用此请求来检查会话是否仍处于活动状态。请提供建议我不知道如何克服这一点。

1 个答案:

答案 0 :(得分:0)

您可以使用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);