How to delete cookies from a website?

Asked

Viewed 316 times

3

1 answer

1


This code forces the expiration of all cookies whose scope is the current website:

function apagaCookies() {
    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";
    }
}

Source: Original post in the OS in English.

  • @Jorgeb. For security restrictions you can only manipulate cookies that belong to the website you are on.

  • Okay, thank you :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.