Clearing all cookies with JavaScript

后端 未结 18 1042
别那么骄傲
别那么骄傲 2020-11-22 05:55

How do you delete all the cookies for the current domain using JavaScript?

18条回答
  •  不思量自难忘°
    2020-11-22 06:20

    Simpler. Faster.

    function deleteAllCookies() {
     var c = document.cookie.split("; ");
     for (i in c) 
      document.cookie =/^[^=]+/.exec(c[i])[0]+"=;expires=Thu, 01 Jan 1970 00:00:00 GMT";    
    }
    

提交回复
热议问题