mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-06 03:13:42 -05:00
Clear old cookies to be based on consent
We have been clearing all the Google Analytics cookies on each page request. It is now possible for a user to consent to having Google Analytics cookies so this should have been checking for that before deleting them. This makes that change, with tests for those scenarios.
This commit is contained in:
@@ -1,15 +1,18 @@
|
||||
// Helper for deleting a cookie
|
||||
function deleteCookie (cookieName) {
|
||||
|
||||
document.cookie = cookieName + '=; path=/; expires=' + (new Date());
|
||||
|
||||
function deleteCookie (cookieName, options) {
|
||||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
||||
if (!options.domain) { options.domain = window.location.hostname; }
|
||||
document.cookie = cookieName + '=; path=/; domain=' + options.domain + '; expires=' + (new Date());
|
||||
};
|
||||
|
||||
function setCookie (name, value, options) {
|
||||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
||||
var cookieString = name + '=' + value + '; path=/;domain=' + window.location.hostname;
|
||||
if (!options.domain) { options.domain = window.location.hostname; }
|
||||
var cookieString = name + '=' + value + '; path=/; domain=' + options.domain;
|
||||
if (options.days) {
|
||||
var date = new Date();
|
||||
date.setTime(date.getTime() + (options.days * 24 * 60 * 60 * 1000));
|
||||
|
||||
Reference in New Issue
Block a user