2022-01-13 15:07:49 +01:00
|
|
|
export function setCookie(name, value) {
|
|
|
|
if (getCookie(name)) {
|
|
|
|
removeCookie(name)
|
|
|
|
}
|
|
|
|
window.document.cookie = `${name}=${value}; Path=/;`
|
2021-04-14 16:43:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export function getCookie(cookieName) {
|
2022-01-13 15:07:49 +01:00
|
|
|
const value = `; ${document.cookie}`
|
|
|
|
const parts = value.split(`; ${cookieName}=`)
|
|
|
|
if (parts.length === 2) {
|
|
|
|
return parts[1].split(";").shift()
|
|
|
|
}
|
2021-04-14 16:43:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
export function removeCookie(cookieName) {
|
|
|
|
if (getCookie(cookieName)) {
|
2022-01-13 15:07:49 +01:00
|
|
|
document.cookie = `${cookieName}=; Max-Age=-99999999; Path=/;`
|
2021-04-14 16:43:34 +02:00
|
|
|
}
|
|
|
|
}
|