- Vue 2
- Nuxt 2
npm:
$ npm install sdz-cookie-vue --save
yarn:
$ yarn install sdz-cookie-vue
Vue 2 Install
// main.js
import Vue from 'vue';
import VueCookieSession from 'sdz-vue-cookie';
Vue.use(VueCookieSession, {
name: '__cookieName',
maxAge: 60 * 60 * 24 * 30,
sameSite: 'lax',
secrets: ['s3cr3ts']
});
Nuxt 2 Install
// plugins/cookie.js
import Vue from 'vue';
import VueCookieSession from 'sdz-vue-cookie';
export default ({ app }, inject) => {
Vue.use(VueCookieSession, {
name: '__cookieName',
maxAge: 60 * 60 * 24 * 30,
sameSite: 'lax',
secrets: ['s3cr3ts']
});
};
// nuxt.config.js
export default {
plugins: [
{ src: '~/plugins/cookie.js', mode: 'client' }
],
};