1.0.3 • Published 3 years ago

@andrewcaires/vue-cookie v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

npm downloads size language commit license

vue-cookie

VueJS plugin for HTTP cookie

Installation

npm i @andrewcaires/vue-cookie

Usage

import VueCookie from '@andrewcaires/vue-cookie';
import Vue from 'vue';

Vue.use(VueCookie, {
  domain: '',
  expires: 86400, // value in milliseconds
  path: '/',
  secure: false,
});

Vue.$cookie.set('token', '...');
const token = Vue.$cookie.get('token');

// OR

export default Vue.extend({
  ...
  created: {
    show() {
      this.$cookie.set('token', '...');
      const token = this.$cookie.get('token');
    }
  },
  ...
});

Api

  • all Get all cookies
const cookies = this.$cookie.all();
  • check Check if a cookie exists
const exists = this.$cookie.check('token');
  • get Get a cookie
const token = this.$cookie.get('token');
  • remove Remove a cookie
this.$cookie.remove('token');
  • set Set a cookie
this.$cookie.set('token', '...');

this.$cookie.set('token', '...', {
  domain: '',
  expires: 86400,
  path: '/',
  secure: false,
});

Links

License