mirror of https://github.com/Budibase/budibase.git
5 changed files with 65 additions and 15 deletions
@ -1,16 +1,26 @@ |
|||
export const Cookies = { |
|||
Auth: "budibase:auth", |
|||
CurrentApp: "budibase:currentapp", |
|||
ReturnUrl: "budibase:returnurl", |
|||
} |
|||
|
|||
export function setCookie(name, value) { |
|||
if (getCookie(name)) { |
|||
removeCookie(name) |
|||
} |
|||
window.document.cookie = `${name}=${value}; Path=/;` |
|||
} |
|||
|
|||
export function getCookie(cookieName) { |
|||
return document.cookie.split(";").some(cookie => { |
|||
return cookie.trim().startsWith(`${cookieName}=`) |
|||
}) |
|||
const value = `; ${document.cookie}` |
|||
const parts = value.split(`; ${cookieName}=`) |
|||
if (parts.length === 2) { |
|||
return parts[1].split(";").shift() |
|||
} |
|||
} |
|||
|
|||
export function removeCookie(cookieName) { |
|||
if (getCookie(cookieName)) { |
|||
document.cookie = `${cookieName}=; Max-Age=-99999999;` |
|||
document.cookie = `${cookieName}=; Max-Age=-99999999; Path=/;` |
|||
} |
|||
} |
|||
|
|||
Loading…
Reference in new issue