Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Cant Use Cookie For Vuex Module Namespace #56

Closed
codeitlikemiley opened this issue Sep 25, 2017 · 3 comments
Closed

Cant Use Cookie For Vuex Module Namespace #56

codeitlikemiley opened this issue Sep 25, 2017 · 3 comments

Comments

@codeitlikemiley
Copy link

codeitlikemiley commented Sep 25, 2017

I tried the Default Declation of createPersistedState() , localstorage works fine...
But I Need to Use Cookies , But I Cant See The Cookie can someone help me with this

import { Store } from 'vuex'
import createPersistedState from 'vuex-persistedstate'
import * as Cookies from 'js-cookie'
/* Add Below All Your Modules */
import auth from './modules/auth'
import permission from './modules/permission'

export default new Store({
    modules: {
        auth,
        permission
        // add modules here
    },
    plugins: [createPersistedState({
        key: App.site.trademark,
        // Declare All The State We Want to Persist
        paths: ['auth.isLoggedIn'],
        storage: {
            getItem: key => Cookies.get(key),
            setItem: (key, value) => Cookies.set(key, value, { expires: 3, secure: true }),
            removeItem: key => Cookies.remove(key)
        }
    })]
})

@codeitlikemiley codeitlikemiley changed the title How to use this on a Module Namespace Vuex? Cant Use Cookie For Vuex Module Namespace Sep 25, 2017
@robinvdvleuten
Copy link
Owner

Have you tried to refresh your browser and looking into the console again? Are you using a secure connection with secure set to true?

@robinvdvleuten
Copy link
Owner

Code in given example should work as expected and no activity by @codeitlikemiley so I am going to close this issue for now.

@codeitlikemiley
Copy link
Author

i opted out of cookies since , we can only have one key of vuex , and cookie is limited , so i revert back to local storage

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants