开发者

How to set Session.Timeout

In ASP.NET application's web.config, I have something like this

开发者_StackOverflow社区<sessionState mode="InProc" cookieless="false" timeout="30"/>
  1. Is this the only place where Sessions timeouts are defined
  2. Is this timeoout in web.config the only one for all the sessions in the application.
  3. Can I not set the session timeouts for each session individually.
  4. IF so, where??
  5. I am looking to use "Keep me Logged-in", where do I have to set the timeout to Maximum


Assuming that "Keep me logged in" goes across sessions, I would set a cookie with an expiry date of a day or a week. Log them in automatically if the cookie exists, or redirect to the login page.

You can set session timeouts in the web.config file as you have described, or in the Global.asax file's Session.Start() function. For example:

protected void Session_Start(object sender, EventArgs e)
{
    Session.Timeout = 30;
}


The keep me logged in has nothing to do with session length, but with the lifetime of the Forms Authentication Cookie.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜