Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Session timeout does not work at asp.net mvc 4 C# . Why?

For my web site I configured login session timeout for 1 week in web.config file

<system.web>
  <httpRuntime />

  <!-- Session keeps for 7 days -->
    <sessionState timeout="10080"></sessionState>
    <authentication mode="Forms">
      <forms loginUrl="~/" timeout="10080" slidingExpiration="true"/>
    </authentication>
  <!-- Configuration end  -->
</system.web>

Here is code for login

    [AllowAnonymous]
    [HttpPost]
    public ActionResult Login(string Login, string Password)
    {
        // empty passwords are not allowed
        if (Password == "")
            return Redirect(Request.UrlReferrer.ToString());

        bool LoginResult = WebSecurity.Login(Login, Password, true);
        return Redirect(Request.UrlReferrer.ToString());
    }

I login, close browser and open it again go to my web site -> user is logged in. I close browser, wait some time (about 30 minutes) go to my web site -> user is logged off. Why? Session should be stored for 7 days but we does not have even 30 minutes. Whan can be the source of problem?

Edit 1 The main idea is that I want to go back to the site in several days and still open it with logged in user

like image 521
Vitalii Avatar asked Apr 02 '14 11:04

Vitalii


People also ask

What is the default session timeout in ASP.NET MVC?

The default is 20 minutes.

What is the default session timeout in C#?

The default is 10 minutes.


1 Answers

Website Session.Timeout will work only when it is less than the application pool session timeout value; because whenever the application pool session timeout value is reached, that particular application pool will be restarted.

http://www.codeproject.com/Articles/113287/Why-Session-Timeout-is-not-working-for-your-websit

like image 83
Ramy Farag Avatar answered Sep 19 '22 19:09

Ramy Farag