Reputation: 81
i'm using Vuex and vuex-persistedstate in my project.
How can I change time to live(ttl) of local storage in Vue?
Sorry for my bad English
P.S. i use this solution When do items in HTML5 local storage expire? .
Upvotes: 0
Views: 1465
Reputation: 20369
vuex-persistedstate seems to be making use of this cookie library:
https://github.com/js-cookie/js-cookie#expires
This example has the expired property as well(taken from their documentatiion):
const store = new Store({
// ...
plugins: [
createPersistedState({
storage: {
getItem: key => Cookies.get(key),
setItem: (key, value) =>
Cookies.set(key, value, { expires: 3, secure: true }),
removeItem: key => Cookies.remove(key),
},
}),
],
})
The number 3 here is the number of days, if you want less you can follow this FAQ:
Upvotes: 1