Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 1x | 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);
const expires = `expires=${d.toUTCString()}`
document.cookie = `${name}=${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;
}
} |