Sholo.Web.Security/Authentication/User/UserAuthentication.cs
/// <summary>
/// Creates an HttpCookie containing an encrypted FormsAuthenticationTicket.
/// The ticket must contain an hash and key into the Provider.
/// </summary>
/// <param name="ticket">The FormsAuthenticationTicket to encode</param>
/// <returns>An HttpCookie containing the encrypted FormsAuthenticationTicket</returns>
Creates an HttpCookie containing an encrypted FormsAuthenticationTicket.
The ticket must contain an hash and key into the Provider.
Creates an HttpCookie containing an encrypted FormsAuthenticationTicket . The ticket must contain an hash and key into the Provider .
public static HttpCookie GetAuthCookie(FormsAuthenticationTicket ticket)
        {
            Initialize();
            string str = FormsAuthentication.Encrypt(ticket);
            if (String.IsNullOrEmpty(str))
            {
                throw new HttpException("Unable to encrypt cookie ticket");
            }
            HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, str)
            {
                HttpOnly = true,
                Path = FormsAuthentication.FormsCookiePath,
                Secure = FormsAuthentication.RequireSSL
            };
            if (FormsAuthentication.CookieDomain != null)
            {
                cookie.Domain = FormsAuthentication.CookieDomain;
            }
            if (ticket.IsPersistent)
            {
                cookie.Expires = ticket.Expiration;
            }
            return cookie;
        }
public static HttpCookie GetAuthCookie ( FormsAuthenticationTicket ticket ) { Initialize ( ) ; string str = FormsAuthentication . Encrypt ( ticket ) ; if ( String . IsNullOrEmpty ( str ) ) { throw new HttpException ( " " ) ; } HttpCookie cookie = new HttpCookie ( FormsAuthentication . FormsCookieName , str ) { HttpOnly = true , Path = FormsAuthentication . FormsCookiePath , Secure = FormsAuthentication . RequireSSL } ; if ( FormsAuthentication . CookieDomain != null ) { cookie . Domain = FormsAuthentication . CookieDomain ; } if ( ticket . IsPersistent ) { cookie . Expires = ticket . Expiration ; } return cookie ; }
Creates an HttpCookie containing an encrypted FormsAuthenticationTicket.
Creates an HttpCookie containing an encrypted FormsAuthenticationTicket .
/*
            if (string.IsNullOrEmpty(ticket.UserData))
            {
                throw new InvalidOperationException("The ticket's UserData property is not set properly.");
            }
            */ // Per http://support.microsoft.com/kb/900111 : // In ASP.NET 2.0, forms authentication cookies are HttpOnly cookies.  // HttpOnly cookies cannot be accessed through client script. This  // functionality helps reduce the chances of replay attacks.
An HttpCookie containing the encrypted FormsAuthenticationTicket
An HttpCookie containing the encrypted FormsAuthenticationTicket
ticket
FormsAuthenticationTicket
The FormsAuthenticationTicket to encode
The FormsAuthenticationTicket to encode