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); }
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); }