如何设置不同的会话超时 [英] How can set different session timeout
问题描述
我们如何在asp.net c#中的网站的每个部分中设置不同的会话超时.
How we can set different session timeout in each part of a website in asp.net c#.
我知道我们可以通过Web配置来管理会话超时,但是当我们在Web配置中更改会话超时时,将为我所有网站设置指定的值,但是我想在程序中管理会话超时,例如在管理员中要设置会话超时2小时,并在登录用户区域中将会话超时设置为10分钟.
I know that we can manage session timeout by web config but when we change session timeout in web config the specified value set for all of my website but I want to manage session timeout in my program for example in administrator want to set session timeout 2 hours and in login user area set session timeout to 10 minute.
推荐答案
您可以更改当前HttpContext的SessionTimeout.管理员登录后,只需按以下方式更改其超时时间:
You can change the SessionTimeout of the current HttpContext. When an administrator logs in, just change his timeout like this:
HttpContext.Current.Session.Timeout = 60;
http://forums.asp.net/t/1563991.aspx
这篇关于如何设置不同的会话超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!