Skip to content

Instantly share code, notes, and snippets.

@jeffskelton3
Created July 16, 2015 16:52
Show Gist options
  • Save jeffskelton3/a3ef3dff1d3b2181420c to your computer and use it in GitHub Desktop.
Save jeffskelton3/a3ef3dff1d3b2181420c to your computer and use it in GitHub Desktop.
takes a given wildcard string and deletes any cookies that contain it in the name
function deleteCookiesByPattern(pattern){
var cookies = document.cookie.split(';');
for(var i=0;i<=cookies.length;i++){
var ck = cookies[i];
if(/pattern/.test(ck)){
document.cookie = ck + '=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;'
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment