Gathering detailed insights and metrics for vue-cookies
Gathering detailed insights and metrics for vue-cookies
Gathering detailed insights and metrics for vue-cookies
Gathering detailed insights and metrics for vue-cookies
vue-cookie
A Vue.js plugin for manipulating cookies
vue3-cookies
A simple Vue.js 3 plugin for handling browser cookies
vue-cookies-reactive
A simple Vue.js plugin for handling browser cookies and refreshing them when a request is made
vue-cookies-ts
A simple Vue.js plugin for handling browser cookies
npm install vue-cookies
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
416 Stars
136 Commits
70 Forks
7 Watchers
2 Branches
14 Contributors
Updated on Jul 15, 2025
Latest Version
1.8.6
Package Id
vue-cookies@1.8.6
Unpacked Size
18.64 kB
Size
5.89 kB
File Count
8
NPM Version
10.9.0
Node Version
22.11.0
Published on
Jan 18, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
No dependencies detected.
A simple Vue.js plugin for handling browser cookies
<script src="https://unpkg.com/vue/dist/vue.js"></script>
<script src="https://unpkg.com/vue-cookies@1.8.6/vue-cookies.js"></script>
npm install vue-cookies --save
// require
var Vue = require('vue')
Vue.use(require('vue-cookies'))
// es2015 module
import Vue from 'vue'
import VueCookies from 'vue-cookies'
// default options config: { expires: '1d', path: '/', domain: '', secure: '', sameSite: 'Lax' , partitioned: false}
Vue.use(VueCookies, { expires: '7d'})
// js
const $cookies = inject('$cookies');
// ts
const $cookies = inject<VueCookies>('$cookies');
$cookies.config(expires[,path[, domain[, secure[, sameSite, [partitioned]]]]) // default: expires = 1d, path = '/', domain = '', secure = '', sameSite = 'Lax', partitioned = ''
$cookies.set(keyName, value[, expires[, path[, domain[, secure[, sameSite, [partitioned]]]]]]) //return this
$cookies.get(keyName) // return value
$cookies.remove(keyName [, path [, domain]]) // return false or true
cookie name
$cookies.isKey(keyName) // return false or true
cookie name
$cookies.keys() // return a array
// 30 day after, expire
Vue.$cookies.config('30d')
// set secure, only https works
Vue.$cookies.config('7d','','',true)
// 2019-03-13 expire
this.$cookies.config(new Date(2019,03,13).toUTCString())
// 30 day after, expire, '' current path , browser default
this.$cookies.config(60 * 60 * 24 * 30,'');
var user = { id:1, name:'Journal',session:'25j_7Sl6xDq2Kc3ym0fmrSSk2xV2XkUkX' };
this.$cookies.set('user',user);
// print user name
console.log(this.$cookies.get('user').name)
Suppose the current time is : Sat, 11 Mar 2017 12:25:57 GMT
Following equivalence: 1 day after, expire
Support chaining sets together
1 // default expire time: 1 day 2this.$cookies.set("user_session","25j_7Sl6xDq2Kc3ym0fmrSSk2xV2XkUkX") 3 // number + d , ignore case 4 .set("user_session","25j_7Sl6xDq2Kc3ym0fmrSSk2xV2XkUkX","1d") 5 .set("user_session","25j_7Sl6xDq2Kc3ym0fmrSSk2xV2XkUkX","1D") 6 // Base of second 7 .set("user_session","25j_7Sl6xDq2Kc3ym0fmrSSk2xV2XkUkX",60 * 60 * 24) 8 // input a Date, + 1day 9 .set("user_session","25j_7Sl6xDq2Kc3ym0fmrSSk2xV2XkUkX", new Date(2017, 03, 12)) 10 // input a date string, + 1day 11 .set("user_session","25j_7Sl6xDq2Kc3ym0fmrSSk2xV2XkUkX", "Sat, 13 Mar 2017 12:25:57 GMT")
this.$cookies.set("default_unit_second","input_value",1); // 1 second after, expire
this.$cookies.set("default_unit_second","input_value",60 + 30); // 1 minute 30 second after, expire
this.$cookies.set("default_unit_second","input_value",60 * 60 * 12); // 12 hour after, expire
this.$cookies.set("default_unit_second","input_value",60 * 60 * 24 * 30); // 1 month after, expire
this.$cookies.set("default_unit_second","input_value",0); // end of session - use 0 or "0"!
Unit | full name |
---|---|
y | year |
m | month |
d | day |
h | hour |
min | minute |
s | second |
Unit Names Ignore Case
not support the combination
not support the double value
1this.$cookies.set("token","GH1.1.1689020474.1484362313","60s"); // 60 second after, expire 2this.$cookies.set("token","GH1.1.1689020474.1484362313","30MIN"); // 30 minute after, expire, ignore case 3this.$cookies.set("token","GH1.1.1689020474.1484362313","24d"); // 24 day after, expire 4this.$cookies.set("token","GH1.1.1689020474.1484362313","4m"); // 4 month after, expire 5this.$cookies.set("token","GH1.1.1689020474.1484362313","16h"); // 16 hour after, expire 6this.$cookies.set("token","GH1.1.1689020474.1484362313","3y"); // 3 year after, expire 7 8// input date string 9this.$cookies.set('token',"GH1.1.1689020474.1484362313", new Date(2017,3,13).toUTCString()); 10this.$cookies.set("token","GH1.1.1689020474.1484362313", "Sat, 13 Mar 2017 12:25:57 GMT ");
var date = new Date;
date.setDate(date.getDate() + 1);
this.$cookies.set("token","GH1.1.1689020474.1484362313", date);
this.$cookies.set("token","GH1.1.1689020474.1484362313", Infinity); // never expire
// never expire , only -1,Other negative Numbers are invalid
this.$cookies.set("token","GH1.1.1689020474.1484362313", -1);
this.$cookies.set("token",value); // domain.com and *.doamin.com are readable
this.$cookies.remove("token"); // remove token of domain.com and *.doamin.com
this.$cookies.set("token", value, null, null, "domain.com"); // only domain.com are readable
this.$cookies.remove("token", null, "domain.com"); // remove token of domain.com
// set path
this.$cookies.set("use_path_argument","value","1d","/app");
// set domain
this.$cookies.set("use_path_argument","value",null, null, "domain.com"); // default 1 day after,expire
// set secure
this.$cookies.set("use_path_argument","value",null, null, null, true);
// set sameSite - should be one of `None`, `Strict` or `Lax`. Read more https://web.dev/samesite-cookies-explained/
this.$cookies.set("use_path_argument","value",null, null, null, null, "Lax");
// set partitioned
this.$cookies.set("use_path_argument","value",null, null, null, true, null, true);
// check a cookie exist
this.$cookies.isKey("token")
// get a cookie
this.$cookies.get("token");
// remove a cookie
this.$cookies.remove("token");
// get all cookie key names, line shows
this.$cookies.keys().join("\n");
// remove all cookie
this.$cookies.keys().forEach(cookie => this.$cookies.remove(cookie))
// vue-cookies global
[this | Vue].$cookies.[method]
$cookies key names Cannot be set to ['expires','max-age','path','domain','secure','SameSite']
MIT Copyright (c) 2016-present, cmp-cc
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 4/26 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-07-14
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More