Gathering detailed insights and metrics for vue-cookies-ts
Gathering detailed insights and metrics for vue-cookies-ts
Gathering detailed insights and metrics for vue-cookies-ts
Gathering detailed insights and metrics for vue-cookies-ts
npm install vue-cookies-ts
Typescript
Module System
Node Version
NPM Version
JavaScript (97.42%)
TypeScript (2.58%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
3 Stars
64 Commits
1 Forks
1 Watchers
3 Branches
1 Contributors
Updated on Mar 10, 2023
Latest Version
1.5.19
Package Id
vue-cookies-ts@1.5.19
Unpacked Size
19.47 kB
Size
4.62 kB
File Count
8
NPM Version
6.12.0
Node Version
10.15.3
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
A simple Vue.js plugin for handling browser cookies
1npm install vue-cookies-ts --save
1import Vue from "vue" 2import VueCookies from "vue-cookies-ts" 3 4Vue.use(VueCookies)
syntax format: [this | Vue | window].$cookies.[method]
Set global config
1(option: CookiesOption) => void 2 3//example 4 5this.$cookies.config({ 6 expires?: string | number | Date, 7 path?: string, 8}) // default: expireTimes = 1d , path=/
Set a cookie
1(key: string, value: any, option: CookiesOption) => VueCookies 2 3//example 4 5this.$cookies.set(keyName: string, { 6 expires?: string | number | Date, 7 path?: string, 8 domain?: string, 9 secure?: boolean 10})
Get a cookie
1(key: string) => string | null | object 2 3//example 4 5this.$cookies.get(keyName: string)
Remove a cookie
1(key: string, option: CookiesOption) => VueCookies | boolean 2 3//example 4 5this.$cookies.remove(keyName: string, {path: string, domain: string})
If exist a cookie name
1(key: string) => boolean 2 3//example 4 5this.$cookies.isKey(keyName: string)
Get All cookie name
1() => string[] 2 3//example 4 5this.$cookies.keys()
1// 30 day after, expire 2this.$cookies.config({ expires: "30d" }) 3 4this.$cookies.config({ expires: new Date(2019,03,13).toUTCString() }) 5 6// 30 day after, expire, '' current path , browser default 7this.$cookies.config({ expires: 60 * 60 * 24 * 30, path: "" }) 8 9// window object 10window.$cookies.config({ expires: "30d" })
1var user = { id:1, name:'Journal', session:'25j_7Sl6xDq2Kc3ym0fmrSSk2xV2XkUkX' } 2 3this.$cookies.set('user', user) 4 5// print user name 6console.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 3 .set("user_session", "25j_7Sl6xDq2Kc3ym0fmrSSk2xV2XkUkX") 4 // number + d , ignore case 5 .set("user_session", "25j_7Sl6xDq2Kc3ym0fmrSSk2xV2XkUkX", { expires: "1d" }) 6 .set("user_session", "25j_7Sl6xDq2Kc3ym0fmrSSk2xV2XkUkX", { expires: "1D" }) 7 // Base of second 8 .set("user_session", "25j_7Sl6xDq2Kc3ym0fmrSSk2xV2XkUkX", { expires: 60 * 60 * 24 }) 9 // input a Date, + 1day 10 .set("user_session", "25j_7Sl6xDq2Kc3ym0fmrSSk2xV2XkUkX", { expires: new Date(2017, 03, 12) }) 11 // input a date string, + 1day 12 .set("user_session", "25j_7Sl6xDq2Kc3ym0fmrSSk2xV2XkUkX", { expires: "Sat, 13 Mar 2017 12:25:57 GMT" })
1// 1 second after, expire 2this.$cookies.set("default_unit_second", "input_value", { expires: 1 }) 3 4// 1 minute 30 second after, expire 5this.$cookies.set("default_unit_second", "input_value", { expires: 60 + 30 }) 6 7// 12 hour after, expire 8this.$cookies.set("default_unit_second", "input_value", { expires: 60 * 60 * 12 }) 9 10// 1 month after, expire 11this.$cookies.set("default_unit_second", "input_value", { expires: 60 * 60 * 24 * 30 })
1// end of session - use string! 2this.$cookies.set("default_unit_second", "input_value", { expires: "0" })
Unit | full name |
---|---|
y | year |
m | month |
d | day |
h | hour |
min | minute |
s | second |
✔ caseless for unit
❌ combination not supported
❌ double value not supported
1// 60 second after, expire 2this.$cookies.set("token","GH1.1.1689020474.1484362313", { expires: "60s" }) 3 4// 30 minute after, expire, ignore case 5this.$cookies.set("token","GH1.1.1689020474.1484362313", { expires: "30min" }) 6 7// 24 day after, expire 8this.$cookies.set("token","GH1.1.1689020474.1484362313", { expires: "24d" }) 9 10// 4 month after, expire 11this.$cookies.set("token","GH1.1.1689020474.1484362313", { expires: "4m" }) 12 13// 16 hour after, expire 14this.$cookies.set("token","GH1.1.1689020474.1484362313", { expires: "16h" }) 15 16// 3 year after, expire 17this.$cookies.set("token","GH1.1.1689020474.1484362313", { expires: "3y" }) 18 19// input date string 20this.$cookies.set('token',"GH1.1.1689020474.1484362313", { expires: new Date(2017,03,13).toUTCString() }) 21 22this.$cookies.set("token","GH1.1.1689020474.1484362313", { expires: "Sat, 13 Mar 2017 12:25:57 GMT " })
1var date = new Date 2 3date.setDate(date.getDate() + 1) 4 5this.$cookies.set("token","GH1.1.1689020474.1484362313", { expires: date })
1// never expire 2this.$cookies.set("token","GH1.1.1689020474.1484362313", { expires: Infinity }) 3 4// never expire , only -1,Other negative Numbers are invalid 5this.$cookies.set("token","GH1.1.1689020474.1484362313", { expires: -1 })
1// set path 2this.$cookies.set("use_path_argument","value", { expires: "1d", path: "/app" }) 3 4// set domain, default 1 day after,expire 5this.$cookies.set("use_path_argument","value", { domain: "domain.com" }) 6 7// set secure 8this.$cookies.set("use_path_argument","value", { secure: true })
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// vue-cookies global 14[this | Vue].$cookies.[method]
$cookies
key names Cannot be set to ['expires','max-age','path','domain','secure']
vue-cookies-ts is developed from vue-cookies, It can exist independently, Friendly to vuejs
MIT Copyright (c) 2016-present, ztytotoro
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file 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 SAST tool detected
Details
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
124 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