0

Recently i heard about formsauthenticationticket class. I need to know how to use this class with user Login? If some can give explanation about this formsauthenticationticket class with example it will be very helpful to me. Thank You

1
  • Why can't you start from Google, some blogs and articles on the internet? That is a better place at this stage. :D
    – codingbiz
    Jan 24, 2013 at 12:20

1 Answer 1

2

FormsAuthenticationTicket has three parameters.parameters are string name, bool isPersistent, and int timeout.The time, in minutes, for which the authentication ticket is valid. if isPersistent is true if the ticket will be stored in a persistent cookie (saved across browser sessions); otherwise, false. If the ticket is stored in the URL, this value is ignored.

Encrypt Method

private string Encrypt(string stringToEncrypt)
{
    FormsAuthenticationTicket tk = new FormsAuthenticationTicket(stringToEncrypt, false, 600);
    // returns encrypted string
    return FormsAuthentication.Encrypt(tk); 
}

Decrypt Method

private string Decrypt(string encryptedString)
{
    FormsAuthenticationTicket tk= FormsAuthentication.Decrypt(encryptedString);
    return tk.Name;
}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.