Handling Cookies In Vue.js – vue-cookies

Description:

A simple Vue.js 3/2 plugin for handling and managing browser cookies.

How to use it:

1. Import and register the plugin.

import Vue from 'vue'
import VueCookies from 'vue-cookies'
Vue.use(VueCookies, { 
  // options here
})

2. Available options.

{ 
  expires: '1d', 
  path: '/', 
  domain: '', 
  secure: '', 
  sameSite: 'Lax' 
}

3. Cookie operations.

// Set a cookie
$cookies.set(keyName, value[, expires[, path[, domain[, secure[, sameSite]]]]])

// Get a cookie
$cookies.get(keyName)

// Remove a cookie
$cookies.remove(keyName [, path [, domain]])

// Exist a cookie name
$cookies.isKey(keyName)

// Get All cookie name
$cookies.keys()

Preview:

vue-cookies

Changelog:

04/27/2022

  • v1.8.1: declare vue3 options api

04/10/2022

  • v1.8.0

04/07/2022

  • Support Vue 3

Download Details:

Author: cmp-cc

Live Demo: https://github.com/cmp-cc/vue-cookies/tree/master/sample

Download Link: https://github.com/cmp-cc/vue-cookies/archive/master.zip

Official Website: https://github.com/cmp-cc/vue-cookies

Install & Download:

# NPM
$ npm i vue-cookies --save

You Might Be Interested In:

Tags:

Add Comment