Exemple #1
0
        public virtual void SetConsentCookie(HttpResponseBase response, bool allowAnalytics = false, bool allowThirdParty = false)
        {
            var expiry = TimeSpan.FromDays(365);

            var cookieData = new ConsentCookie
            {
                AllowAnalytics  = allowAnalytics,
                AllowThirdParty = allowThirdParty
            };

            var consentCookie = new HttpCookie(ConsentCookieName)
            {
                // Store JSON serialized object which contains current allowed types (Analytics & ThirdParty) in cookie.
                Value   = JsonConvert.SerializeObject(cookieData),
                Expires = DateTime.UtcNow + expiry
            };

            response.Cookies.Set(consentCookie);
        }
Exemple #2
0
        public virtual void SetConsentCookie(HttpResponseBase response, bool allowAnalytics = false, bool allowThirdParty = false)
        {
            var expiry = TimeSpan.FromDays(365);

            var cookieData = new ConsentCookie
            {
                AllowAnalytics  = allowAnalytics,
                AllowThirdParty = allowThirdParty
            };

            var secure        = _services.WebHelper.IsCurrentConnectionSecured();
            var consentCookie = new HttpCookie(ConsentCookieName)
            {
                // Store JSON serialized object which contains current allowed types (Analytics & ThirdParty) in cookie.
                Value    = JsonConvert.SerializeObject(cookieData),
                Expires  = DateTime.UtcNow + expiry,
                Secure   = secure,
                SameSite = secure ? (SameSiteMode)_privacySettings.SameSiteMode : SameSiteMode.Lax
            };

            response.Cookies.Set(consentCookie);
        }