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? .
Asked
Active
Viewed 1,202 times
0

Ksenia Subbotina
- 81
- 6
-
What have you tried so far? – kboul Oct 08 '18 at 07:44
-
Now, i have 2 different solutions for this question. One - use js-cookie in store, second - use solution https://stackoverflow.com/questions/2326943/when-do-items-in-html5-local-storage-expire . Now, i use window.localStorage in my project – Ksenia Subbotina Oct 09 '18 at 12:14
1 Answers
1
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:

Stephan-v
- 19,255
- 31
- 115
- 201