用户不活动时如何结束会话 [英] How can i end session when user was inactive

查看:97
本文介绍了用户不活动时如何结束会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我已经看到了有关本次会议的几个例子.但是我想知道以下是否按照我的要求工作.我的要求是我将有一些用户可以访问的页面.如果用户访问某个页面,并且如果他在5分钟左右未执行任何操作,那么我想将他重定向到可用的默认页面.我已经引用了以下文章 ASP.NET中的警报会话超时 [

Hi all i have seen several examples regarding the session. But i would like to know whether the following work as per my requirement or not. My requirement i will have some pages that user can access. If user visits a page and if he didn''t perform any operations for 5 minutes or so i would like to redirect him to the default page available. I have referred the following article Alert Session Time out in ASP.NET[^]

But this shows the session expiration even when i am working on the page. I would like to impllement some thing like net banking application, when user is inactive for few minutes i would like say your session has been expired and redirect him to the login page any idea please

推荐答案

当用户单击注销按钮时,
在该按钮中单击事件
清除所有cookie并写
When User click on Logout button,
in that button click event
clear all cookies and write
session.abandon();



在web.config中,在
标签下面写



In web.config write below tag in

<system.web> tag
<sessionstate timeout="60" /></system.web>



如果您使用表单身份验证,则可以设置
表单标签的



If you are using forms authentication then you can set

slidingExpiration

属性为

"true"



请通过这些链接

http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.slidingexpiration.aspx [ ^ ]

http://msdn.microsoft.com/en-us/library/1d3t3c61.aspx [ ^ ]



Please go through these links

http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.slidingexpiration.aspx[^]

http://msdn.microsoft.com/en-us/library/1d3t3c61.aspx[^]


您好,


您必须遵循一些流程.

让我告诉您我在客户端聊天应用程序中的表现如何

首先,我创建了3分钟超时的会话变量

然后在我的JavaScript中,我有一种方法可以在每个
中将数据从客户端发布到服务器 1分钟

在我的服务器端,我有一种方法可以处理异步请求,以扩展会话变量的时间.

在此过程中,客户端javascript每1分钟调用一次服务器方法
如果不是,则表示客户端未处于活动状态,则会话会自动
超时超时后清除

通过此过程,我在客户端网站上实现了我的聊天应用.

在这里我只说了示例时间以进行解释

您可以根据需要设置会话变量的超时时间

我希望你能理解我说的话

最好的
Hi,


you''ve to follow some process for it.

Let me tell you how I did in my client chat app

First I created session variable with 3 min timeout

then in my javascript i''ve one method to post data from client to server in every
1 min

In my server side i''ve one method to handle that asyncronous request to extend timout of session variable.

In this process the server method invoked by client javascript in every 1 min
If not that means the client is no active then the session is automatically
cleared when its timeout time overs

By this process I achieve my chat app in client website.

Here I just said example timings for explanation

you can set timeouts of session variables As your requirement

I hope you understood What I said

All the Best


这篇关于用户不活动时如何结束会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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