Sha256: 1e99cc8c75770269d2483eb965bf1ea6ac101ed09a3cc5ea89fe76a951f1e5b1
Contents?: true
Size: 664 Bytes
Versions: 12
Compression:
Stored size: 664 Bytes
Contents
export function getCookie(name) { const cookies = document.cookie ? document.cookie.split("; ") : [] const prefix = `${encodeURIComponent(name)}=` const cookie = cookies.find(cookie => cookie.startsWith(prefix)) if (cookie) { const value = cookie.split("=").slice(1).join("=") return value ? decodeURIComponent(value) : undefined } } export function setCookie(name, value) { const twentyYears = 20 * 365 * 24 * 60 * 60 * 1000 const body = [ name, value ].map(encodeURIComponent).join("=") const expires = new Date(Date.now() + twentyYears).toUTCString() const cookie = `${body}; path=/; expires=${expires}` document.cookie = cookie }
Version data entries
12 entries across 12 versions & 1 rubygems