Files
ARTEX/web/src/lib/cookie.client.ts
T
Autumn-27andClaude Opus 4.8 0ef8561411 chore: ARTEX 初始化
ARTEX — AI 自主渗透测试系统(Go 后端 + Next.js 前端,单二进制内嵌)。

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-07-26 04:27:45 -04:00

25 lines
866 B
TypeScript

// 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=/`);
}