15 lines
563 B
TypeScript
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`;
|
|
}
|