“JavaScript Hapus Cookie” Kode Jawaban

Bersihkan 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();
Lokesh003Coding

JavaScript Hapus Cookie

function deleteCookie(name) {
  document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}
TC5550

Hapus cookie dengan domain javascript

document.cookie = 'my_cookie=; path=/; domain=.example.com; expires=' + new Date(0).toUTCString();
Yellowed Yak

cara menghapus cookie di 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"

cara menghapus node cookie js

cookies.set('testtoken', {expires: Date.now()});
Unusual Unicorn

Membersihkan kue di JS

document.cookie.split(";")
  .forEach(function(c) { 
  	document.cookie = c.replace(/^ +/, "").replace(/=.*/, "=;expires=" + new Date().toUTCString() + ";path=/"); });
Real Rabbit

Jawaban yang mirip dengan “JavaScript Hapus Cookie”

Pertanyaan yang mirip dengan “JavaScript Hapus Cookie”

Lebih banyak jawaban terkait untuk “JavaScript Hapus Cookie” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya