Last active
December 13, 2022 14:24
-
-
Save jason-murray/efc5e9300c4113ffa45efcd4d0b99f24 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// You can fill the below with lines that cover the paths you want to clear cookies for. | |
// We found that the issue started around November 4th, so we decided to clear cookies for | |
// all posts and category pages from October 15th onwards. The list of paths was generated | |
// by querying the CMS. | |
// The script also sets and checks a localStorage value to avoid reruns, and will be retired | |
// from production after a certain amount of time. | |
const p = []; | |
// For example, if you want to clear cookies for the following paths: | |
// BEGIN PATHS | |
p.push('/category/opinion/comment'); | |
p.push('/category/competitions'); | |
// END PATHS | |
if (JSON.parse(localStorage.getItem('vf-cleanup-finished')) !== true) { | |
for (let index = 0; index < p.length; index++) { | |
// You must add a Domain= attribute to this string with the relevant value | |
document.cookie = '_vfa=;expires=Thu, 01 Jan 1970 00:00:01 GMT;path=' + p[index]; | |
} | |
localStorage.setItem('vf-cleanup-finished', 'true'); | |
console.log ('VF Cleanup Complete'); | |
} else { | |
console.log ('VF Cleanup Not Required'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment