Website/utils/cookies.ts
TheClashFruit 844a9060de
All checks were successful
Lint Codebase / lint (push) Successful in 1m10s
feat: Next.js rewrite
2024-08-29 15:20:28 +02:00

19 lines
534 B
TypeScript

export function getCookie(name: string): string | null {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2)
return decodeURIComponent(parts.pop()?.split(';').shift()!) || null;
return null;
}
export function getCookieFromContext(name: string, cookie: string): string | null {
const value = `; ${cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2)
return decodeURIComponent(parts.pop()?.split(';').shift()!) || null;
return null;
}