Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

javascript get all cookies

var getCookies = function(){
  var pairs = document.cookie.split(";");
  var cookies = {};
  for (var i=0; i<pairs.length; i++){
    var pair = pairs[i].split("=");
    cookies[(pair[0]+'').trim()] = unescape(pair.slice(1).join('='));
  }
  return cookies;
}

var myCookies = getCookies();
console.log(myCookies);
Comment

get all cookies

let c = document.cookie.split(";").reduce( (ac, cv, i) => Object.assign(ac, {[cv.split('=')[0]]: cv.split('=')[1]}), {});

console.log(c);
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to debug jest test vscode 
Javascript :: basic server on node.js 
Javascript :: how to use jquery timepicker 
Javascript :: vue cli - Uncaught SyntaxError: Unexpected token < 
Javascript :: react typed js 
Javascript :: javascript does not equal 
Javascript :: nextjs check production or development environment 
Javascript :: vowel 
Javascript :: assign class to element javascript 
Javascript :: count number of each element in array javascript 
Javascript :: js sting first letter 
Javascript :: js window location relative path 
Javascript :: javascript howdo i redirect-to another webpage 
Javascript :: safeareaview react native android 
Javascript :: miles to metres js 
Javascript :: trigger input javascript 
Javascript :: check if var is NaN 
Javascript :: remove special characters from string 
Javascript :: javascript check if variable is a jquery object 
Javascript :: javascript array add 
Javascript :: npm shrinkwrap primordials 
Javascript :: localstorage javascript array 
Javascript :: how to fill array with consecutive numbers javascript 
Javascript :: change span value javascript 
Javascript :: include cookies in fetch 
Javascript :: downgrade node version windows using npm 
Javascript :: ion input ios keyboard over 
Javascript :: javascript cors error 
Javascript :: javascript localstorage 
Javascript :: past value from parent in reactjs 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =