JSFiddle - React, Tailwind, and code Playground
HTML
<div id="log1">
</div>
<hr>
<div id="log2">
</div>
fff
JavaScript
document.cookie = "key1=value1";
document.cookie = "key2=value2";
$('#log1').html(document.cookie);
//Makes an array of the Cookies
let pairs = document.cookie.split(";");
//Dictionary
let cookieDictionary={};
//Loops through the cookies and assigns them to a dictionary.
for(let p of pairs)
{
let vals = p.split("=");
cookieDictionary[vals[0]] = vals[1];
}
//Create a key for easy cookie lookup
let cookieKeys = Object.keys(cookieDictionary);
console.log(cookieKeys);
$('#log2').html(cookieKeys);