Download ARTEX-main/web/src/lib/cookie.client.ts from ghostai1/WardenPEN: direct link, hf CLI and curl.
- Browser
- Download file 866 Bytes
-
https://huggingface.co/ghostai1/WardenPEN/resolve/main/ARTEX-main/web/src/lib/cookie.client.ts
- Command line
-
hf download hf://ghostai1/WardenPEN/ARTEX-main/web/src/lib/cookie.client.ts
-
curl -L -o cookie.client.ts https://huggingface.co/ghostai1/WardenPEN/resolve/main/ARTEX-main/web/src/lib/cookie.client.ts
866 Bytes
| // Client-side cookie utilities. | |
| // These functions manage cookies in the browser only. | |
| // Server actions handle cookie updates on the server side. | |
| function writeClientCookie(serializedCookie: string) { | |
| // biome-ignore lint/suspicious/noDocumentCookie: This project still uses document.cookie for broad browser support. | |
| document.cookie = serializedCookie; | |
| } | |
| export function setClientCookie(key: string, value: string, days = 7) { | |
| const expires = new Date(Date.now() + days * 864e5).toUTCString(); | |
| writeClientCookie(`${key}=${value}; expires=${expires}; path=/`); | |
| } | |
| export function getClientCookie(key: string) { | |
| return document.cookie | |
| .split("; ") | |
| .find((row) => row.startsWith(`${key}=`)) | |
| ?.split("=")[1]; | |
| } | |
| export function deleteClientCookie(key: string) { | |
| writeClientCookie(`${key}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/`); | |
| } | |