function setCookie(key, value) {
const exdate=new Date();
exdate.setDate(exdate.getDate() + 1);
document.cookie=`${key}=${value}; expires=` + exdate.toUTCString() +
"; samesite=lax";
}
function getCookie(key) {
const cookies = decodeURIComponent(document.cookie).split('; ')
const cookie = cookies.find(el => el.startsWith(key));
return cookie.substring(cookie.indexOf('=') + 1);
}
Last active
September 14, 2022 23:03
-
-
Save Lovor01/bdeaffc3f6735083e1da7f8277412ba9 to your computer and use it in GitHub Desktop.
Get/set cookie
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment