Answers for "how to delete a cookie in js"

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

how to delete a cookie in js

//set the vvalue to EMPTY, and the date to an already PASSED one.
document.cookie = "cookiename= ; expires = Thu, 01 Jan 1970 00:00:00 GMT"
Posted by: Guest on February-06-2021
1

js delete cookie by name

var removing = browser.cookies.remove(
  details               // object
)
Posted by: Guest on October-28-2020
0

delete cookie 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