简体   繁体   English

如何设置不同的会话超时

[英]How can set different session timeout

How we can set different session timeout in each part of a website in asp.net c#. 我们如何在ASP.NET C#网站的每个部分中设置不同的会话超时。

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. 我知道我们可以通过Web配置来管理会话超时,但是当我们在Web配置中更改会话超时时,将为我所有网站设置指定的值,但是我想在程序中管理会话超时,例如在管理员中要设置会话超时2小时并在登录用户区域中将会话超时设置为10分钟。

You can change the SessionTimeout of the current HttpContext. 您可以更改当前HttpContext的SessionTimeout。 When an administrator logs in, just change his timeout like this: 管理员登录后,只需更改其超时,如下所示:

HttpContext.Current.Session.Timeout = 60;

http://forums.asp.net/t/1563991.aspx http://forums.asp.net/t/1563991.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM