0

im kind of new on mvc 3 and i just spot this on a sample project in mvc 2

FormsAuthenticationTicket authTicket = new FormsAuthenticationTicket(1,Username,DateTime.Now,DateTime.Now.AddMinutes(10), RememberMe, Username);
string encTicket = FormsAuthentication.Encrypt(authTicket);
this.Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, encTicket));

and this on a mvc 3 sample project

FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);

My question is does this have the same effect ?? how do i specify the live of the cookie on mvc 3 ??

Thx in advance

1 Answer 1

2

My question is does this have the same effect ??

No, the two code fragments are not equivalent because in the first you are manually setting the timeout validity of the ticket to 10 minutes whereas in the second it uses the Timeout property in your web.config:

<authentication mode="Forms">
  <forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>

It would have had the same effect if you set the timeout in web.config to 10 minutes.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.