Author: mikecollins | Posted on: 9/17/2008 9:36:11 AM | Views : 374

I am trying to use FormsAuthentication to save a user's preference to stay logged in, but in testing, when I have not logged in for a few hours (not sure of the exact time), I have to add my username again. In our case, we are not taking the user straight in, we just populate the the username and check the box that says remember it. Can someone show me where it is not right...why I have to re-add my username after a few hours of not logging in?

 //Setting the cookie
FormsAuthenticationTicket ticket = null;

if (cbRemember.Checked)
ticket = new FormsAuthenticationTicket(
1,
txtUserName.Text,
DateTime.Now,
DateTime.Now.AddYears(1),
true,
String.Empty);
else
ticket = new FormsAuthenticationTicket(
1,
txtUserName.Text,
DateTime.Now,
Dat ...

Go to the complete details ...