Gathering detailed insights and metrics for vue-cookies-reactive
Gathering detailed insights and metrics for vue-cookies-reactive
Gathering detailed insights and metrics for vue-cookies-reactive
Gathering detailed insights and metrics for vue-cookies-reactive
A simple Vue.js plugin for handling browser cookies
npm install vue-cookies-reactive
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
1 Stars
98 Commits
1 Forks
3 Branches
1 Contributors
Updated on Sep 08, 2021
Latest Version
2.1.1
Package Id
vue-cookies-reactive@2.1.1
Unpacked Size
16.31 kB
Size
5.44 kB
File Count
6
NPM Version
7.22.0
Node Version
14.15.5
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
1
3
A simple Vue.js plugin for handling browser cookies reactively, heavily inspired by vue-cookies This lib overrides the default fetch and XMLHttpRequest implementations to reload cookies after a request is executed, allowing you to use cookies as computed properties or to watch cookies for changes made by a request
1npm install vue-cookies-reactive --save
1// require 2var Vue = require('vue') 3Vue.use(require('vue-cookies-reactive')) 4 5// es2015 module 6import Vue from 'vue' 7import VueCookies from 'vue-cookies-reactive' 8Vue.use(VueCookies) 9 10// set default config 11Vue.$cookies.config('7d') 12 13// set global cookie 14Vue.$cookies.set('theme','default'); 15Vue.$cookies.set('hover-time','1s');
syntax format: [this | Vue].$cookies.[method]
Set global config
1$cookies.config(expireTimes[,path[, domain[, secure[, sameSite]]]) // default: expireTimes = 1d, path = '/', domain = '', secure = '', sameSite = 'Lax'
Set a cookie
1$cookies.set(keyName, value[, expireTimes[, path[, domain[, secure[, sameSite]]]]]) //return this
Get a cookie or all cookies as an object if no key is passed
1$cookies.get(keyName) // return value
Remove a cookie
1$cookies.remove(keyName [, path [, domain]]) // return this
Check if a cookie is set
1$cookies.isKey(keyName) // return false or true
Get all keys of cookies
1$cookies.keys() // return an array
Refresh all cookies, note that this is already done automatically after each XMLHttpRequest
or fetch
are executed so it's unlikely you will need it
1$cookies.resfresh() // return this
1// 30 day after, expire 2Vue.$cookies.config('30d') 3 4// set secure, only https works 5Vue.$cookies.config('7d','','',true) 6 7// 2019-03-13 expire 8this.$cookies.config(new Date(2019,03,13).toUTCString()) 9 10// 30 day after, expire, '' current path , browser default 11this.$cookies.config(60 * 60 * 24 * 30,''); 12
1var user = { id:1, name:'Journal',session:'25j_7Sl6xDq2Kc3ym0fmrSSk2xV2XkUkX' }; 2this.$cookies.set('user',user); 3// print user name 4console.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")
1this.$cookies.set("default_unit_second","input_value",1); // 1 second after, expire 2this.$cookies.set("default_unit_second","input_value",60 + 30); // 1 minute 30 second after, expire 3this.$cookies.set("default_unit_second","input_value",60 * 60 * 12); // 12 hour after, expire 4this.$cookies.set("default_unit_second","input_value",60 * 60 * 24 * 30); // 1 month after, expire
1this.$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 ");
1var date = new Date; 2date.setDate(date.getDate() + 1); 3this.$cookies.set("token","GH1.1.1689020474.1484362313", date);
1this.$cookies.set("token","GH1.1.1689020474.1484362313", Infinity); // never expire 2// never expire , only -1,Other negative Numbers are invalid 3this.$cookies.set("token","GH1.1.1689020474.1484362313", -1);
1this.$cookies.set("token",value); // domain.com and *.doamin.com are readable 2this.$cookies.remove("token"); // remove token of domain.com and *.doamin.com 3 4this.$cookies.set("token", value, null, null, "domain.com"); // only domain.com are readable 5this.$cookies.remove("token", null, "domain.com"); // remove token of domain.com
1// set path 2this.$cookies.set("use_path_argument","value","1d","/app"); 3 4// set domain 5this.$cookies.set("use_path_argument","value",null, null, "domain.com"); // default 1 day after,expire 6 7// set secure 8this.$cookies.set("use_path_argument","value",null, null, null,true); 9 10// set sameSite - should be one of `None`, `Strict` or `Lax`. Read more https://web.dev/samesite-cookies-explained/ 11this.$cookies.set("use_path_argument","value",null, null, null, null, "Lax");
1// check a cookie exist 2this.$cookies.isKey("token") 3 4// get a cookie 5this.$cookies.get("token"); 6 7// remove a cookie 8this.$cookies.remove("token"); 9 10// get all cookie key names, line shows 11this.$cookies.keys().join("\n"); 12 13// remove all cookie 14this.$cookies.keys().forEach(cookie => this.$cookies.remove(cookie)) 15 16// vue-cookies global 17[this | Vue].$cookies.[method] 18
$cookies key names Cannot be set to ['expires','max-age','path','domain','secure','SameSite']
This is a limitation of cookies and not this lib
MIT Copyright (c) 2020, Tofandel
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
no SAST tool detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
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
11 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
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