“Bersihkan Cookies JS” 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

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"

JavaScript Bersihkan semua cookie

const clearCookies = document.cookie.split(';').forEach(cookie => document.cookie = cookie.replace(/^ +/, '').replace(/=.*/, `=;expires=${new Date(0).toUTCString()};path=/`));
Rashid Siddique

Membersihkan kue di JS

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

Hapus cookie dengan javascript

document.cookie = "username=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
Ivan Cuaco

Jawaban yang mirip dengan “Bersihkan Cookies JS”

Pertanyaan yang mirip dengan “Bersihkan Cookies JS”

Lebih banyak jawaban terkait untuk “Bersihkan Cookies JS” di JavaScript

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya