Created
April 21, 2015 14:39
-
-
Save normanzb/ee8ffede036a6c63a655 to your computer and use it in GitHub Desktop.
new cookie clearing script
This file contains hidden or 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
<script> | |
(function() { | |
function setCookie(name, value, days) { | |
var expires; | |
if (days) { | |
var date = new Date(); | |
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000)); | |
expires = "; expires=" + date.toGMTString(); | |
} else { | |
expires = ""; | |
} | |
document.cookie = name + "=" + value + expires + "; path=/"; | |
} | |
function removeCookie(name) { | |
setCookie(name, "", -1); | |
} | |
function getCookieNames() { | |
var ret = []; | |
var cookieStrings = document.cookie.split(';'); | |
var currentCookieString = ''; | |
for(var i = 0; i < cookieStrings.length; i++) { | |
currentCookieString = cookieStrings[i]; | |
ret.push(currentCookieString.substring(0, currentCookieString.indexOf('='))); | |
} | |
return ret; | |
} | |
function removeAllQTagCookies() { | |
var cookieNames = getCookieNames(); | |
var cookieName; | |
for(var l = cookieNames.length; l--;) { | |
cookieName = cookieNames[l]; | |
if (cookieName.indexOf('qtag_') >= 0) { | |
removeCookie(cookieName); | |
} | |
} | |
} | |
removeAllQTagCookies(); | |
})(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment