From d491c1bad64a538d670cc7631fe659df64ae867d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfgang=20Hu=C3=9F?= Date: Wed, 19 Jan 2022 09:23:08 +0100 Subject: [PATCH] Add expiration date and sameSite attribute to lacale cookie --- webapp/plugins/i18n.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/webapp/plugins/i18n.js b/webapp/plugins/i18n.js index 8c64ef0c3..44005db62 100644 --- a/webapp/plugins/i18n.js +++ b/webapp/plugins/i18n.js @@ -29,7 +29,13 @@ export default ({ app, req, cookie, store }) => { return } - app.$cookies.set(key, newLocale) + const expires = new Date() + expires.setDate(expires.getDate() + app.$env.COOKIE_EXPIRE_TIME) + app.$cookies.set(key, newLocale, { + expires, + // maxAge: app.$env.COOKIE_EXPIRE_TIME * 60 * 60 * 24, // days to seconds + sameSite: 'lax', + }) if (!app.$i18n.localeExists(newLocale)) { import(`~/locales/${newLocale}.json`).then((res) => { app.$i18n.add(newLocale, res.default)