Vue cannot read cookies at load time and load it into store of Vuex

problem description

I am using Vue to develop the front end of an application. I want to use both store and cookies of vuex to save the user"s login information. My implementation method is as follows: after the user logs in, save the user information and the isLogin field in vuex"s store and cookies, and then vue-router jumps to the user backend. (vue-router verifies whether the isLogin field in the store of vuex is true to determine the user"s login status.) When the Vue is loaded ( mounted ) I also write the function to read and write the relevant cookies to store, but this does not take effect after each refresh, so the user is always required to log in again. Want to know how to modify it? Thank you!

related codes

1. initialization of Vue in main.js :
router.beforeEach((to, from, next) => {
  //requiresAuth
  if(to.meta.requiresAuth){//
    if(store.state.account.isLogin == true){
      next();
    }else{
      next({
        path: "/login",
        query: { redirect: to.fullPath } 
      });
    }

}else if (to.meta.requiresNoAuth) {//
    if(store.state.account.isLogin == false){
      next();
    }else{
      next({
        path: "/"
      });
    }
}{
    next();
  }
});
The

problem has been solved because when vue-router routing verifies the login state in state, the user information has not been written into state, so you only need to write the user information in cookie to state before verifying the state login state in vue-router.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1be3924-3168f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1be3924-3168f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?