0👍
You’re using this.$cookies
outside the Vue context, where this
is probably window
.
To resolve the issue, replace this.$cookies
with Vue.$cookies
to set a global cookie, or move this.$cookies
to a component method/hook.
Example usage based on the docs:
//...
Vue.use(VueCookies)
// set global cookie
Vue.$cookies.set('theme', 'default');
// set cookie from Vue context
new Vue({
mounted() {
this.$cookies.set('theme', 'default');
}
})
Source:stackexchange.com