如何使带有警报框的会话超时 [英] how to make session timeout with alert box

查看:63
本文介绍了如何使带有警报框的会话超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用程序中使用Spring Security,java.当会话过期时,我需要显示会话已结束的警报.框上应该有一个确定按钮,单击该按钮后,我想重定向到登录页面.我应该在其中放置最大超时时间,并在超时后显示警报消息.

I am using spring security, java in application. When the session gets expired, I need to show an alert that the session is over. The box should have an ok button which, when clicked, I want to redirect to login page.where should i put max time out and display alert message after time out.

推荐答案

假设加载新页面后会话超时计时器已重置,则只需使用JavaScript超时即可:

Assuming that the session timeout timer is reset once a new page is loaded, you can simply use a JavaScript timeout:

setTimeout(function() {
    if(confirm('session timeout'))
        location.href = 'login.html';
}, 15 * 60 * 1000); // 15 minutes, alter appropriately

导航到另一个页面后,所有当前的JavaScript都会被丢弃,因此超时将被重置.

As soon as you navigate to another page, all current JavaScript is discarded, so the timeout will be reset.

这篇关于如何使带有警报框的会话超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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