Closed eeerrrttty closed 4 years ago
@eeerrrttty do you use https? Otherwise secure
needs to be set to false
.
Yes i do use HTTPS :)
Do you have a codesandbox to reproduce the issue?
Bro, how can i reproduce it ? It has no secrets, you can create a project in a framework you prefer and simple paste my code in the 'plugins' of vuex.
Make sure you don't exceed max cookie size (4096 Bytes). That was a problem I had. No error given but the plugin didn't save data to the cookie.
@eeerrrttty do you use https? Otherwise
secure
needs to be set tofalse
.
What about the case using localstorage
instead of cookies? How do we set it to false
?
I do need large amount of data to be stored
@eeerrrttty so if you have a large amount of data, cookies should not be used. Please use LocalStorage for such cases.
I have the same problem. When page refresh data will not refresh using js-cookies. Making secure: false fix the problem. I'm in localhost
@neverender24 it's not a problem; secure: true
only works on https, so when developing locally on http your cookies are not set as its not secure.
I am facing the same issue, this is is my own settings
plugins: [
createPersistedState({
paths: ["account.token"],
key: "token",
storage: {
getItem: key => Cookie.getJSON(key),
setItem: (key, state) =>
Cookie.set(key, state, {
expires: 3,
secure: false
}),
removeItem: key => Cookie.remove(key)
}
})
]
I wanted to save a token that is stored in anaccount.js
module for an SPA. Everything works fine, could navigate through all other page using router-link(SPA) but once I reload the whole page, the cookie resets to the default state
I am gonna close this issue as all code within the comments contain bugs not related to the plugin. Please move any question related to configuring or setting up the plugin to Stackoverflow or the Vuejs forum.