2026-03-19 03:36:46 +01:00
|
|
|
const SESSION_COOKIE = 'nxtgauge_admin_session';
|
2026-03-20 22:37:17 +01:00
|
|
|
const SESSION_VALUE = 'internal_management';
|
2026-03-19 03:36:46 +01:00
|
|
|
const SESSION_TTL_SECONDS = 60 * 60 * 12;
|
|
|
|
|
|
|
|
|
|
export function hasAdminSession(): boolean {
|
|
|
|
|
if (typeof document === 'undefined') return false;
|
2026-03-20 22:37:17 +01:00
|
|
|
return document.cookie.split(';').some((entry) => entry.trim() === `${SESSION_COOKIE}=${SESSION_VALUE}`);
|
2026-03-19 03:36:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function setAdminSession(): void {
|
|
|
|
|
if (typeof document === 'undefined') return;
|
2026-03-20 22:37:17 +01:00
|
|
|
document.cookie = `${SESSION_COOKIE}=${SESSION_VALUE}; Path=/; Max-Age=${SESSION_TTL_SECONDS}; SameSite=Lax`;
|
2026-03-19 03:36:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function clearAdminSession(): void {
|
|
|
|
|
if (typeof document === 'undefined') return;
|
|
|
|
|
document.cookie = `${SESSION_COOKIE}=; Path=/; Max-Age=0; SameSite=Lax`;
|
|
|
|
|
}
|