Skip to content

Commit

Permalink
Properly delete GA cookies instead of just wiping the value
Browse files Browse the repository at this point in the history
When Google Analytics cookies were being 'deleted', the values were actually just being wiped/set to blank.
This commit expands the deletion code to specify a domain and path, and hardcode the expiry
  • Loading branch information
Vanita Barrett committed Jul 28, 2021
1 parent 75508e8 commit 89625ef
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions src/javascripts/components/cookie-functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,8 @@ function setCookie (name, value, options) {
}

function deleteCookie (name) {
document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT'

// If the cookie still exists, let's try a more thorough way of deleting it,
// by specifying the domain and path
if (Cookie(name)) {
document.cookie = name + '=;expires=' + new Date() + ';domain=' + window.location.hostname.replace(/^www\./, '.') + ';path=/'
document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:00 GMT;domain=' + window.location.hostname + ';path=/'
document.cookie = name + '=;expires=Thu, 01 Jan 1970 00:00:00 GMT;domain=.' + window.location.hostname + ';path=/'
}
}

0 comments on commit 89625ef

Please sign in to comment.