interface COOKIEYC { set: (name: string, value: string, exdays: number) => void; get: (name: string) => string | undefined; } // cookie export const YC: COOKIEYC = { set: (name: string, value: string, exdays: number): void => { const d = new Date(); d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000); const expires = `expires=${d.toUTCString()}`; document.cookie = `${name}=${escape(value)};${expires};path=/`; }, get: (name: string): string | undefined => { const str = `${name}=`; const ca = document.cookie.split(';'); for (let i = 0; i < ca.length; i += 1) { let c = ca[i]; while (c.charAt(0) === ' ') c = c.substring(1); if (c.indexOf(str) !== -1) return c.substring(str.length, c.length); } return undefined; }, };