1var getCookies = function(){
2 var pairs = document.cookie.split(";");
3 var cookies = {};
4 for (var i=0; i<pairs.length; i++){
5 var pair = pairs[i].split("=");
6 cookies[(pair[0]+'').trim()] = unescape(pair.slice(1).join('='));
7 }
8 return cookies;
9}
10
11var myCookies = getCookies();
12console.log(myCookies);
1let c = document.cookie.split(";").reduce( (ac, cv, i) => Object.assign(ac, {[cv.split('=')[0]]: cv.split('=')[1]}), {});
2
3console.log(c);