Asp.net:实施自动注销功能 [英] Asp.net: Implementing Auto-Logout functionality

查看:171
本文介绍了Asp.net:实施自动注销功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要实现我的一个项目,我只是不能断定从哪里开始寻找的想法,但自动注销功能的 SO

I have to implement auto-logout functionality in one of my projects and i just cant figure out where to start looking for ideas but SO.

我需要的是应用程序将用户重定向到登录页面,如果用户会话已过期。  请告诉我,什么应该是我的方法来解决这一要求。

What i need is for the application to redirect the user to the login page if the user session has expired. Please tell me as to what should be my approach to tackle this requirement.

问题描述: 如果用户离开系统超过n分钟,在任何给定的登录情况下,系统将自动登录它们关闭。

Problem Statement: If the user leaves the system for more than n minutes in any given log-in instance, the system should automatically log them off.

推荐答案

此已经通过以下方式实现的:

This has been achieved by the following way:

1)除每个请求的时间戳(服务器和AJAX不包括会话检查Ajax请求)的服务器到会话变种。

1) Save the time-stamp of every request( server and ajax excluding the session check ajax request) to the server into a session var.

2)用ajax在频繁通过JS功能轮询服务器,并检查会话时间戳和Ajax请求的时间之间的时间差异大于会话超时VAL然后注销当前用户,并返回一个布尔值,为Ajax请求。

2) Poll the server via a JS function using ajax at frequent intervals and check if the time diff between the session time-stamp and the ajax request time is greater than the session timeout val then log-off the current user and return a bool for that ajax request.

3)重定向当前页面到登录页面,如果布尔返回的是真实的。

3) Redirect the current page to the login page if the bool returned is true.

这篇关于Asp.net:实施自动注销功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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