void SetCookie(string value)
        {
            DateTime?expires = null;

            if (String.IsNullOrWhiteSpace(value))
            {
                var existingValue = GetCookie();
                if (existingValue == null)
                {
                    // no need to write cookie to clear if we don't already have one
                    return;
                }

                value   = ".";
                expires = DateTime.Now.AddYears(-1);
            }

            var opts = new Microsoft.AspNet.Http.CookieOptions
            {
                HttpOnly = true,
                Secure   = Secure,
                Path     = CookiePath,
                Expires  = expires
            };

            _context.HttpContext.Response.Cookies.Append(CookieName, value, opts);
        }
Ejemplo n.º 2
0
        void SetCookie(string value)
        {
            DateTime? expires = null;
            if (String.IsNullOrWhiteSpace(value))
            {
                var existingValue = GetCookie();
                if (existingValue == null)
                {
                    // no need to write cookie to clear if we don't already have one
                    return;
                }

                value = ".";
                expires = DateTime.Now.AddYears(-1);
            }

            var opts = new Microsoft.AspNet.Http.CookieOptions
            {
                HttpOnly = true,
                Secure = Secure,
                Path = CookiePath,
                Expires = expires
            };

            _context.HttpContext.Response.Cookies.Append(CookieName, value, opts);
        }