From 564c0633cf5ae9cff1f34f4937f3e43b027fc46a Mon Sep 17 00:00:00 2001 From: Seppe Dekeyser Date: Mon, 1 Jul 2024 20:57:17 +0200 Subject: [PATCH] Store docs preferences in localStorage instead (#1311) --- site/src/components/Toolbar.svelte | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/site/src/components/Toolbar.svelte b/site/src/components/Toolbar.svelte index 5ceb8dcd4..da769aca0 100644 --- a/site/src/components/Toolbar.svelte +++ b/site/src/components/Toolbar.svelte @@ -14,14 +14,16 @@ { label: 'dark', icon: 'sun' } ] + const COOKIE_TIMEOUT = 60 * 60 * 24 * 365 // One year + function setLang() { - document.cookie = `lang=${other_lang};path=/;SameSite=Lax` + document.cookie = `lang=${other_lang};path=/;SameSite=Lax;max-age=${COOKIE_TIMEOUT}` lang = other_lang } function setTheme() { ui_theme = ui_theme ? 0 : 1 - document.cookie = `ui_theme=${ui_theme};path=/;SameSite=Lax` + document.cookie = `ui_theme=${ui_theme};path=/;SameSite=Lax;max-age=${COOKIE_TIMEOUT}` }