function clearCookie() { if (document.cookie == '') { console.log('clear done!'); return; } var cookieEntries = document.cookie.split(';'); for (var i = 0; i < cookieEntries.length; i++) { var name = cookieEntries[i].split('=')[0]; var exp = new Date(); exp.setTime(exp.getTime() - 1); document.cookie = name + "=1" + ";expires=" + exp.toGMTString(); } }