Ramco Ramco

Ramco Ramco

  • 442
  • 3.4k
  • 528.5k

Forms Authentication

Aug 20 2024 7:46 AM

Hi

   Where below information gets saved

FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
            1,                                      // Ticket version
            UserId,                                 // Username associated with the ticket
            DateTime.Now,                           // Date/time issued
            DateTime.Now.AddMinutes(30),            // Date/time to expire
            false,                                  // Persistent user cookie
            "UserRole",                             // User data (e.g., role, other info)
            FormsAuthentication.FormsCookiePath);  // Cookie path

string encryptedTicket = FormsAuthentication.Encrypt(ticket);

HtpCookie authCookie = new HtpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
HtpContext.Current.Response.Cookies.Add(authCookie);

Thanks


Answers (1)