Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to timeout a user in asp.net formsAuthentication
    text
    copied!<p>I am wondering how do I set a timeout for a user if they don't do any requests after say 10mins there session is killed and they are logged out.</p> <p>I have in my webconfig this </p> <pre><code>&lt;authentication mode="Forms"&gt; &lt;forms loginUrl="~/Account/LogOn" protection="All" timeout="20160" path="/" requireSSL="false" slidingExpiration="false" defaultUrl="default.aspx" cookieless="UseDeviceProfile" enableCrossAppRedirects="false" /&gt; &lt;/authentication&gt; </code></pre> <p>I was told to set timeout to equal "20160" because I wanted to be logged in for 2 weeks if they checked the "stay logged in for 2 weeks". I also make sure to enable IsPersistent in my cookie Cookie.</p> <p>So is there another timeout I need to set? Since after a certain time of inactivity on my site it does not work anymore. I have not timed it but say if I leave and come back 10mins later and try to do something on my site like saving something it won't work. So it looks like my connection was killed or something. I have to signout, log back in and then it works</p> <p>Edit</p> <p>This is how I make my cookie</p> <pre><code> FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(version,userName,DateTime.UtcNow,DateTime.UtcNow.AddDays(14),createPersistentCookie,userData,"/"); string encryptedTicket = FormsAuthentication.Encrypt(authTicket); HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket); authCookie.Path = "/"; if (createPersistentCookie == true) { authCookie.Expires = DateTime.UtcNow.AddDays(14); } HttpContext.Current.Response.Cookies.Add(authCookie); </code></pre> <p>When I do set session state in my webconfig my url has this in it</p> <pre><code>(S(gkvkze55zfzzee45wj34byee)) </code></pre> <p>I rather not have this nasty line in my code.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload