Пример #1
0
        public static void SaveCookie()
        {
            string ticketText = UserTicketLogic.NewTicket(GetDevice());

            HttpCookie cookie = new HttpCookie(CookieName, ticketText)
            {
                Expires = DateTime.UtcNow.Add(UserTicketLogic.ExpirationInterval),
            };

            System.Web.HttpContext.Current.Response.Cookies.Add(cookie);
        }
Пример #2
0
        public static void SaveCookie(ActionContext ac)
        {
            var httpConnection = ac.HttpContext.Features.Get <IHttpConnectionFeature>();

            string ticketText = UserTicketLogic.NewTicket(httpConnection.LocalIpAddress.ToString());

            ac.HttpContext.Response.Cookies.Append(CookieName, ticketText, new CookieOptions
            {
                Domain  = ac.HttpContext.Request.Host.Host.ToString(),
                Expires = DateTime.UtcNow.Add(UserTicketLogic.ExpirationInterval),
            });
        }