Vuex Persisten State duplicate key
-
Hi Friends
I am using vuex-persistenstate to persist data across cokkies with a boot.
import { Cookies } from 'quasar' import createPersistedState from 'vuex-persistedstate' export default function ({ store, ssrContext }) { const cookies = process.env.SERVER ? Cookies.parseSSR(ssrContext) : Cookies createPersistedState({ key: '_mtdc', paths: ['auth.token', 'auth.profileUser'], storage: { getItem (key) { return JSON.stringify(cookies.get(key)) }, setItem (key, value) { console.log(key, value) cookies.set(key, value, { expires: 30, path: '/' }) }, removeItem (key) { cookies.remove(key) } } })(store) }
But cookies are repeating in the browser
Set-Cookie: _mtdc=%7B%22auth%22%3A%7B%22token%…
Any suggestions on how I could avoid this behavior
Thanks -
Maybe quasar’s cookie plugin allows duplicate keys? What if you first check if the cookie key exists before doing cookies.set?
See here:
https://quasar.dev/quasar-plugins/cookies#Verify-if-Cookie-is-Set