UNPKG

cheetah-framework

Version:

Cheetah Framework JS used in all our applications

23 lines (18 loc) 538 B
export default class Cookie { static get (key) { const cookies = document.cookie.split('; ') for (const cookie of cookies) { const [cookieKey, cookieValue] = cookie.split('=') if (cookieKey === key) { return cookieValue } } } static set (key, value, daysBeforeExpiration = 720) { const maxAge = daysBeforeExpiration * 24 * 60 * 60 document.cookie = `${key}=${value}; max-age=${maxAge}; path=/;` } static remove (key) { document.cookie = key + '=; max-age=-1; path=/;' } }