Add a way to login to your account on the website

This commit is contained in:
2026-01-30 18:46:54 -07:00
parent a0e64af3ce
commit ae63c449fa
6 changed files with 130 additions and 6 deletions

16
src/util/cookie.ts Normal file
View File

@@ -0,0 +1,16 @@
export function setCookie (name: string, value: string): void {
const maxAge = 60 * 60 * 24 * 90
const cookie = `${encodeURIComponent(name)}=${encodeURIComponent(
value
)}; Path=/; Max-Age=${maxAge}; Secure; SameSite=Strict`
document.cookie = cookie
}
export function getCookie (name: string, defaultValue: string): string {
const cookies = document.cookie.split('; ')
for (const c of cookies) {
const [k, v] = c.split('=')
if (decodeURIComponent(k) === name) return decodeURIComponent(v)
}
return defaultValue
}