formsauthentication

  • Thread starter Thread starter Grant Merwitz
  • Start date Start date
G

Grant Merwitz

Hi, i am using forms authentication in an ASP.NET project

I am setting the Forms authentication cookie by using:
FormsAuthentication.RedirectFromLoginPage(UserName.Text, false);

Now when i review my trace on my page, there are two cookies created that
look identical.
When i FormsAuthentication.SignOut() they both dissappear.

Any ideas as to why two cookies are created?

TIA
 
Grant,

Is this a local app you are debugging or on the live server? Try setting
the domain property of the cookie. That may clear up the double cookie
problem.

Janaka
 
Try setting it this way: I've set the cookie to timeout after 20 minutes
but you can change this

FormsAuthenticationTicket authTicket = new
FormsAuthenticationTicket(tbUserName.Text, false, 20);

// Encrypt and store the ticket

string encryptTicket = FormsAuthentication.Encrypt(authTicket);

HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName,
encryptTicket);

authCookie.Domain = ConfigurationSettings.AppSettings["domain"];

// Redirect

Response.Cookies.Add(authCookie);

Response.Redirect(FormsAuthentication.GetRedirectUrl(tbUserName.Text,
false));
 
Back
Top