Skip to content

Instantly share code, notes, and snippets.

@nathanbrauer
Last active December 14, 2021 22:50
Show Gist options
  • Save nathanbrauer/ef27090fc5b02d3da99671b1c4122d77 to your computer and use it in GitHub Desktop.
Save nathanbrauer/ef27090fc5b02d3da99671b1c4122d77 to your computer and use it in GitHub Desktop.
/**
* A function which takes your e-junkie cl number and deletes all cart cookies related to your account
*/
function deleteCartCookies(cl) {
var cookies = document.cookie.split(";");
var cl = Number(cl);
var cookie, eqPos, name;
for (var i = 0; i < cookies.length; i++) {
cookie = cookies[i];
if (cookie.indexOf(cl + "=") > -1) {
eqPos = cookie.indexOf("=");
name = cookie.substr(0, eqPos);
document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/; domain=." + window.location.host + ";";
}
}
}
// Usage:
deleteCartCookies(123456);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment