Answers for "Delete a Cookie with JavaScript"

6

clear cookies js

function deleteAllCookies() {
    var cookies = document.cookie.split(";");

    for (var i = 0; i < cookies.length; i++) {
        var cookie = cookies[i];
        var eqPos = cookie.indexOf("=");
        var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
        document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT";
    }
}

deleteAllCookies();
Posted by: Guest on June-27-2020
5

javascript delete cookie

function deleteCookie(name) {
  document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}
Posted by: Guest on May-20-2020
1

clearing cookie in js

document.cookie.split(";")
  .forEach(function(c) { 
  	document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/"); });
Posted by: Guest on December-23-2020
0

Delete a Cookie with JavaScript

document.cookie = "username=; expires=Thu, 01 
Jan 1970 00:00:00 UTC; path=/;";
Posted by: Guest on August-25-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language