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);
精彩评论