开发者

remove session(Maintained using cookies) if user is idle for 15 minutes

开发者 https://www.devze.com 2023-02-22 16:09 出处:网络
I am using \"cookies\" to maintain session in my asp.net azure application. What I want is that when a 开发者_如何学Gouser logs in to my website and remains idle for 15 minutes it should automaticall

I am using "cookies" to maintain session in my asp.net azure application.

What I want is that when a 开发者_如何学Gouser logs in to my website and remains idle for 15 minutes it should automatically log them out and redirect them to the login page.

How can I achieve this?


In web.config

<configuration> <system.web> <compilation debug="true" targetFramework="4.0"/> <sessionState timeout="15"/> </system.web> </configuration>


You can use Expires property of HttpCookie object:

HttpCookie SessionCookie = new HttpCookie("Session");
DateTime now = DateTime.Now;
SessionCookie.Expires = now.AddMinutes(15);
Response.Cookies.Add(SessionCookie);
0

精彩评论

暂无评论...
验证码 换一张
取 消