0

Usually I have:

<authentication mode="Forms">
<forms loginUrl="Login.aspx"
   timeout="30"
   slidingExpiration="true"
</authentication>

which (IMHO) means that the cookie expires after 30 minutes of inactivity - sliding expiration means that any activity sets the cookie's expiry time back to 30 minutes.

Now I have the requirement that I would like the cookie to be stored indefinately, unless the user logs out explicitly. This means, that even if the browser is closed and reopened and the user goes to a side that requires authentication, no login is required. Is this possible?

cs0815
  • 16,751
  • 45
  • 136
  • 299
  • Possible duplicate of http://stackoverflow.com/questions/549/the-definitive-guide-to-forms-based-website-authentication#477579 – nunespascal Feb 28 '13 at 10:50

2 Answers2

1

What you describe sounds equivalent to forcing the remember me checkbox to always be checked. To achieve that, go to your your Login action, and do the following:

FormsAuthentication.SetAuthCookie(username, true);
Daniel Liuzzi
  • 16,807
  • 8
  • 52
  • 57
0

use SetAuthCookie method. SetAuthCookie

FormsAuthentication.SetAuthCookie(UserID, false); // not persisting cookie accross the browser session.

FormsAuthentication.SignOut().// for signout

Ravi Gadag
  • 15,735
  • 5
  • 57
  • 83