Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript delete cookie

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

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();
Comment

javascript Clear All Cookies

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

delete cookies by domain javascript

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

how to destroy cookie in javascript

function delCookie(name){
	document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT; path=/;';
}
Comment

clearing cookie in js

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

js delete all cookies

function del_cookies() {
  /*Split Cookies into a two-dimensional array:*/
  var c_a = document.cookie.split (';').map(cookie => cookie.split('='));
  var c = 0;
  /*Repeat following prozess for the number of cookies*/
  while (c < c_a.length) {
    /*Get first element of every array inside the c_a array:*/
    var c_a_name = c_a[c][0];
    
    /*DEBUGGING: (logs the name of the cookies in the console)*/
    /* console.log(c_a[c][0]); */
    
    /*set the expire date to some date in the past to delete the cookie:*/
    document.cookie = c_a_name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/";
    /*increase c to get the next array*/
    c++;
  }
}
/*
  Note:
  
    This deleats ALL cookies!
    -----
	If this doesn't work for you, change the path for deleting the cookie.
    You may create new cookies, if it's the wrong path.
    -----
    Two-dimensional cookie array:
    [
    ['cookie_name_1', value_1],
	['cookie_name_2', value_2],
    ['cookie_name_3', value_3],
	]
*/
Comment

PREVIOUS NEXT
Code Example
Javascript :: javascript look hack 
Javascript :: javamailsender schedular 
Javascript :: captureEvents 
Javascript :: log errors react 
Javascript :: mongoose geospatial Schema Options 
Javascript :: F:JavascriptOOP 
Javascript :: javascript debugging methods 
Javascript :: react default value for props not showing up 
Javascript :: iterating hashmap angular 
Javascript :: order by ascending descending in angular 6 on click of button 
Javascript :: node red using tcp request 
Javascript :: get day first 3 letters name in js 
Javascript :: graphql Int cannot represent non-integer value 
Javascript :: getting form value(s) with js 
Javascript :: client.guilds foreach 
Javascript :: session cookie vs persistent cookie 
Javascript :: javascript remove junk element from array 
Javascript :: how to print date in javascript without time 
Javascript :: routing in react jps 
Javascript :: point towards mouse wick editor 
Javascript :: Detectando url diferente em nodeJs 
Javascript :: which element is focused javascript console 
Javascript :: jaavascript loop array 
Javascript :: convert var to string jquery 
Javascript :: <xsl:apply-templates select node text subnodes all 
Javascript :: search and delete instances of node_modules in directory 
Javascript :: jest check the link of a button 
Javascript :: How to select a search bar without a `name`? javascript 
Javascript :: react component in for loop 
Javascript :: react native bottom bar curved 
ADD CONTENT
Topic
Content
Source link
Name
6+3 =