parent
8286cdd41d
commit
41ef9fd49f
@ -1,20 +0,0 @@
|
||||
export const setCookie = (name: string, value: unknown, days: number) => {
|
||||
let expires = "";
|
||||
if (days) {
|
||||
const date = new Date();
|
||||
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
||||
expires = "; expires=" + date.toUTCString();
|
||||
}
|
||||
document.cookie = name + "=" + (value || "") + expires + "; path=/";
|
||||
};
|
||||
|
||||
export const getCookie = (name: string): unknown | undefined => {
|
||||
const nameEquals = name + "=";
|
||||
const ca = document.cookie.split(";");
|
||||
for (let i = 0; i < ca.length; i++) {
|
||||
let c = ca[i];
|
||||
while (c.charAt(0) == " ") c = c.substring(1, c.length);
|
||||
if (c.indexOf(nameEquals) == 0) return c.substring(nameEquals.length, c.length);
|
||||
}
|
||||
return undefined;
|
||||
};
|
Loading…
Reference in new issue