开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜