Hello I am using this js-cookie within vuex store. Now would you please tell me what I need to write in my logout component so I can logout and clear this cookie. Here is my code of vuex store.
const store = new Vuex.Store({
strict: true,
plugins: [
createPersistedState({
storage: {
getItem: key => Cookies.get(key),
setItem: (key, value) =>
Cookies.set(key, value, { expires: 3, secure: true }),
removeItem: key => Cookies.remove(key)
}
})
],
})
export default store
@umardraz I wasn't aware that I've created an authentication mechanism. This is an issue / question about your application, not an issue with this plugin. Please ask such question a forum or stackoverflow.
@robinvdvleuten I believe what the OP is asking is how to call removeItem and can you provide an example.
I am having the same issue... When I use the plugin, the application data persists for all that login, so how can you clear the Cookie/LS, or SecureLS with your plugin?
I assume there is a global way to use the plugin that is the equivalent of this...
for LocalStorage:
localStorage.removeItem('vuex');
for Cookies:
import * as Cookies from 'js-cookie'
Cookie.remove('vuex');
for SecureLS:
import SecureLS from "secure-ls";
const ls = new SecureLS({ isCompression: false });
ls.remove('vuex');
how do you access createPersistedState > storage > removeItem('vuex") to globally remove the entire key? The examples stop short of showing how to delete everything, and only focus on deleting single properties using the store itself. An enterprise application could have many things that need to persist, not just a string or two. Instead of having to call a large handful of modules to clear the store properties, I just want to delete everything associated with that key in storage.
How can that be done?
Keep in mind that this one exists in case you ended up here: https://github.com/robinvdvleuten/vuex-persistedstate/issues/88
Most helpful comment
@robinvdvleuten I believe what the OP is asking is how to call
removeItemand can you provide an example.I am having the same issue... When I use the plugin, the application data persists for all that login, so how can you clear the Cookie/LS, or SecureLS with your plugin?
I assume there is a global way to use the plugin that is the equivalent of this...
for LocalStorage:
for Cookies:
for SecureLS:
how do you access
createPersistedState > storage > removeItem('vuex")to globally remove the entire key? The examples stop short of showing how to delete everything, and only focus on deleting single properties using the store itself. An enterprise application could have many things that need to persist, not just a string or two. Instead of having to call a large handful of modules to clear the store properties, I just want to delete everything associated with that key in storage.How can that be done?