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

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 :: target child event 
Javascript :: change class js 
Javascript :: get max height from array element jqeury 
Javascript :: math.round in javascript 
Javascript :: react-load-animations 
Javascript :: passing argument to function handler functional compoent javascript react 
Javascript :: how to give icon in input type file react 
Javascript :: discord.js if no arguments 
Javascript :: C# Convert Json File to DataTable 
Javascript :: js how to get max sub array sum 
Javascript :: hashing passwords with bcrypt 
Javascript :: where is select value in javascript event object 
Javascript :: javascript get last word in string 
Javascript :: remove id from array javascript 
Javascript :: maximum number in javascript 
Javascript :: vue js convert string to html 
Javascript :: next js cookie 
Javascript :: byte to integer js 
Javascript :: ckeditor inline editor example 
Javascript :: Error: ENOENT: no such file or directory, lstat ode_modules@react-navigationcoresrcgetStateFromPath.tsx 
Javascript :: Substring in Javascript using substr 
Javascript :: onclose modal bootstrap 
Javascript :: loop react components 
Javascript :: row smaller than the container bootstrap react 
Javascript :: how to add two times in javascript 
Javascript :: connect to existing collection mongoose 
Javascript :: javascript loop counter 
Javascript :: set date to input date 
Javascript :: defining schema mongoose 
Javascript :: date picker type react 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =