Answer The simplest way to create a cookie is to assign a string value to the document.cookie object, for example- document.cookie = "key1 = value1; key2 = value2; expires = date"; // Example var now = new Date(); now.setTime(now.getTime() + 1 * 3600 * 1000); //set cookies to expire in 1 hour document.cookie = `${key} = ${value}; ${opt} = ${opt_value}; expires = ${now.toUTCString()};`; const cookie = document.cookie will return all cookies in one string much like: cookie1=value; cookie2=value; cookie3=value; Share this:TwitterFacebookRedditLinkedInWhatsAppPrintTumblr Related