feat(favs): Sterne-Favoriten pro Sound; Speicherung per Cookie (ohne Login)

This commit is contained in:
vibe-bot 2025-08-08 03:21:01 +02:00
parent f619cac653
commit 99588e446c
3 changed files with 70 additions and 6 deletions

18
web/src/cookies.ts Normal file
View file

@ -0,0 +1,18 @@
export function setCookie(name: string, value: string, days = 365): void {
const expires = new Date(Date.now() + days * 24 * 60 * 60 * 1000).toUTCString();
document.cookie = `${encodeURIComponent(name)}=${encodeURIComponent(value)}; expires=${expires}; path=/; SameSite=Lax`;
}
export function getCookie(name: string): string | null {
const key = `${encodeURIComponent(name)}=`;
const parts = document.cookie.split(';');
for (const part of parts) {
const trimmed = part.trim();
if (trimmed.startsWith(key)) {
return decodeURIComponent(trimmed.slice(key.length));
}
}
return null;
}