Skip to content

Instantly share code, notes, and snippets.

@exussum12
Created December 18, 2013 09:41
Show Gist options
  • Save exussum12/8019726 to your computer and use it in GitHub Desktop.
Save exussum12/8019726 to your computer and use it in GitHub Desktop.
Nuke Cookies - attempt many combinations of cookie pathname + hosts and try to clear them all
function nukeCookies(quiet) {
if(typeof quiet == undefined) quiet = false;
var cookies = $.cookie();
var hosts = window.location.hostname.split(".");
var path = window.location.pathname.split("/");
path.shift();
for(var cookie in cookies) {
//domain and path need to match, Try some combinations
$.removeCookie(cookie);
for(i = 0; i < hosts.length; i++){
$.removeCookie(cookie, {domain: "." + hosts.slice(i,hosts.length).join(".")});
$.removeCookie(cookie, {domain: hosts.slice(i,hosts.length).join(".")});
for(j=0; j< path.length; j++){
$.removeCookie(cookie, {domain: "." + hosts.slice(i,hosts.length), path: "/" + path.slice(0,j).join("/")});
$.removeCookie(cookie, {domain: hosts.slice(i,hosts.length), path: "/" + path.slice(0,j).join("/")});
}
}
}
if(!quiet){
alert("Cookies have been cleared");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment