private static void CreateDefaultIdentityCookie(UserClaim userClaim)
        {
            var now = DateTime.Now;
            var claimJson = userClaim.ToJson();

            var ticket = new FormsAuthenticationTicket(1,
                                                       userClaim.Username,
                                                       now,
                                                       now.Add(FormsAuthentication.Timeout),
                                                       false,
                                                       claimJson,
                                                       FormsAuthentication.FormsCookiePath);

            // Encrypt the ticket.
            string encTicket = FormsAuthentication.Encrypt(ticket);

            // Create the cookie.
            var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket)
                         {
                             Domain = FormsAuthentication.CookieDomain,
                             HttpOnly = true,
                             Path = FormsAuthentication.FormsCookiePath
                         };

            HttpContext.Current.Response.Cookies.Add(cookie);
        }
        public void SetAuthenticationTicket(UserClaim userClaim)
        {
            var provider = FormsAuthCookieProvider.CurrentProvider;
            if (provider == null) {
                throw new InvalidOperationException("FormsAuthentication Cookie Provider is null.");
            }

            provider(userClaim);
        }