用户驱动的会话过期 [英] User driven session expiration

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

问题描述

我需要给我的ASP.NET网站用户的方式来控制他们的会话超时。
我使用的FormsAuthenticationTicket 饼干

I need to give my ASP.NET website users a way to control their session timeout. I am using FormsAuthenticationTicket and cookies.

我想给用户的方式来指定会议将停留多久活跃。的范围可以为1天或甚至更几分钟之间变化。

I want to give the users a way to specify how long the session will stay active. The range can vary between a few minutes to 1 day or even more.

我用的idleTimeout (我问了一个问题<一href=\"http://stackoverflow.com/questions/6149341/difference-between-idletimeout-and-shutdowntimeout/6149360#6149360\">here).

I'm using idleTimeout (I asked a question here).

此外,我省使用该值初始化我通过在数据库中的用户输入的值和的FormsAuthenticationTicket

Also, I save the value entered by the user in the database and using that value I initialize the FormsAuthenticationTicket.

我有2个更多的关注:应用程序池和饼干。我的网站在一个专用的应用程序池运行。我是否需要更改的idleTimeout 属性的应用程序池,太?不编程,当然。

I have 2 more concerns: Application Pool and cookie. My website runs under a dedicated App Pool. Do I need to change the idleTimeout property for App Pool, too? Not programmatically, of course.

总之,要那句我的问题:其他设置需要什么才能做有会话过期动态设置的和工作无论什么时间间隔

Anyway, to phrase my question: what other settings need to be done in order to have the session expiration dynamically set and working no matter what time interval?

感谢。

编辑:我使用的IIS7在Windows Server 2008上的机

I am using IIS7 on a Windows Server 2008 machine.

推荐答案

这是不是一个好主意有一个会话超时太长,你会保持忙碌一些资源的服务器上,如果你的Web应用程序是通过大量的访问不同的用户它可能会影响服务器的性能。

it is never a good idea have a session time out too long as you will keep busy some resource on the server and if your web app is accessed by lots of different user it could affect the server performance.

反正你可以改变会话超时编程方式使用低于code

Anyway you can just change the session time out programmatically using the below code

Session.TimeOut= [=nMinutes]

记住,会话超时应小于应用程序池空闲超时,所以如果增加会话超时,你要提高应用程序的空闲超时了。否则,应用程序将得到回收。如果应用程序被回收,会话将自动失效。

bear in mind that session timeout should be less than Application pool idle timeout, so if you increase session timeout, you have to increase application idle timeout too. Otherwise, application will get recycled. If application is recycled, sessions will expire automatically.

允许的最小值为1分钟,最大值为1440分钟。

The minimum allowed value is 1 minute and the maximum is 1440 minutes.

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

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