Skip to content

Commit

Permalink
fix: fixed cookie getting set in different paths from client side whe…
Browse files Browse the repository at this point in the history
…n language was changed^C
  • Loading branch information
Raj Nandan Sharma authored and Raj Nandan Sharma committed Feb 8, 2025
1 parent 13879ae commit 786c4f8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/routes/(kener)/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
* @param {string} locale
*/
function setLanguage(locale) {
document.cookie = `localLang=${locale};max-age=${60 * 60 * 24 * 365 * 30}`;
document.cookie = `localLang=${locale};max-age=${60 * 60 * 24 * 365 * 30};path=${base ? "base" : "/"};`;
if (locale === defaultLocaleKey) return;
defaultLocaleValue = allLocales[locale];
analyticsEvent("language_change", {
Expand All @@ -58,7 +58,12 @@
let localTz = Intl.DateTimeFormat().resolvedOptions().timeZone;
if (localTz != data.localTz) {
if (data.isBot === false) {
document.cookie = "localTz=" + localTz + ";max-age=" + 60 * 60 * 24 * 365 * 30;
document.cookie =
"localTz=" +
localTz +
";max-age=" +
60 * 60 * 24 * 365 * 30 +
`;path=${base ? "base" : "/"};`;
location.reload();
}
}
Expand Down

0 comments on commit 786c4f8

Please sign in to comment.