I've developed a web application for our users and they should only login once.
Everytime they return to the application, they should be logged in automaticcaly.
Therefore I've set the expiration time 50 years ahead when they log in.
// login
// Create the ticket, and add the groups.
FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket( 1,
txtName.Text, DateTime.Now, DateTime.Now.AddYears( 50 ), true, dataCookie );
// Encrypt the ticket.
string encryptedTicket = FormsAuthentication.Encrypt( authTicket );
// Create a cookie, and then add the encrypted ticket to the cookie as data.
HttpCookie authCookie = new HttpCookie( FormsAuthentication.FormsCookieName, encryptedTicket );
authCookie.Expires = DateTime.Now.AddYears( 50 );
// web.config
<authentication mode="Forms">
<!-- timeout: 50 years -->
<forms loginUrl="login.aspx" n ...
Go to the complete details ...