Files
place4bees.com/frontend/src/lib/customerCookie.ts
T
2026-09-17 16:02:51 +02:00

15 lines
563 B
TypeScript

export const CUSTOMER_COOKIE_NAME = "customer_jwt";
export function getCustomerTokenClient(): string | null {
const match = document.cookie.match(new RegExp(`(?:^|; )${CUSTOMER_COOKIE_NAME}=([^;]*)`));
return match ? decodeURIComponent(match[1]) : null;
}
export function setCustomerTokenClient(token: string) {
document.cookie = `${CUSTOMER_COOKIE_NAME}=${encodeURIComponent(token)}; path=/; max-age=${60 * 60 * 24 * 30}; SameSite=Lax`;
}
export function clearCustomerTokenClient() {
document.cookie = `${CUSTOMER_COOKIE_NAME}=; path=/; max-age=0`;
}