The easiest way to get cookies in JS
const getCookie = (name) => document.cookie.match(`[;\s+]?${name}=([^;]*)`)?.pop(); // For example, the cookie is as follows: a=b; c=d // use getCookie(‘c’) // d where match is the prototype method for strings. str.match(regexp) If a non-regex object is passed in, it is implicitly converted to a RegExp using new RegExp(obj) The above, so there is no need to […]
The easiest way to get cookies in JS Read More »