Gathering detailed insights and metrics for tiny-cookie
Gathering detailed insights and metrics for tiny-cookie
Gathering detailed insights and metrics for tiny-cookie
Gathering detailed insights and metrics for tiny-cookie
npm install tiny-cookie
Typescript
Module System
Node Version
NPM Version
JavaScript (58.46%)
TypeScript (27.33%)
HTML (12.4%)
Shell (1.82%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
112 Stars
143 Commits
14 Forks
3 Watchers
4 Branches
3 Contributors
Updated on Dec 19, 2024
Latest Version
2.5.1
Package Id
tiny-cookie@2.5.1
Unpacked Size
38.20 kB
Size
8.56 kB
File Count
13
NPM Version
8.19.3
Node Version
18.13.0
Published on
Nov 04, 2023
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
23
English | 简体中文
A tiny cookie manipulation plugin for browser.
Upgrade from 1.x to 2.x: You can check the CHANGELOG.md
If you're used tiny-cookie, then you may be interest in micell, a collection of functions focusing on web development.
NPM:
1npm install tiny-cookie
ES2015 (recommended)
1// You can import all methods. 2import * as Cookies from 'tiny-cookie' 3 4// Or, you can import the methods as needed. 5import { isEnabled, get, set, remove } from 'tiny-cookie' 6 7// No alias required, just imports. 8import { isCookieEnabled, getCookie, setCookie, removeCookie } from 'tiny-cookie'
The tiny-cookie will expose an object Cookie
on the global scope. Also, it can be as a CommonJS/AMD module (recommended).
Alias: isCookieEnabled
Check if the cookie is enabled.
Alias: getCookie
Get the cookie value with decoding, using decodeURIComponent
.
Alias: getRawCookie
Get the cookie value without decoding.
Alias: getAllCookies
Get all cookies with decoding, using decodeURIComponent
.
Alias: setCookie
Set a cookie with encoding the value, using encodeURIComponent
. The options
parameter is an object. And its property can be a valid cookie option, such as path
(default: root path /
), domain
, expires
/max-age
, samesite
or secure
(Note: the secure
flag will be set if it is an truthy value, such as true
, or it will be not set). For example, you can set the expiration:
1import { setCookie } from 'tiny-cookie'; 2 3const now = new Date; 4now.setMonth(now.getMonth() + 1); 5 6setCookie('foo', 'Foo', { expires: now.toGMTString() });
The expires
property value can accept a Date
object, a parsable date string (parsed by Date.parse()
), an integer (unit: day) or a numeric string with a suffix character which specifies the time unit.
Unit suffix | Representation |
---|---|
Y | One year |
M | One month |
D | One day |
h | One hour |
m | One minute |
s | One second |
Examples:
1import { setCookie } from 'tiny-cookie'; 2const date = new Date; 3 4date.setDate(date.getDate() + 21); 5 6setCookie('dateObject', 'A date object', { expires: date }); 7setCookie('dateString', 'A parsable date string', { expires: date.toGMTString() }); 8setCookie('integer', 'Seven days later', { expires: 7 }); 9setCookie('stringSuffixY', 'One year later', { expires: '1Y' }); 10setCookie('stringSuffixM', 'One month later', { expires: '1M' }); 11setCookie('stringSuffixD', 'One day later', { expires: '1D' }); 12setCookie('stringSuffixh', 'One hour later', { expires: '1h' }); 13setCookie('stringSuffixm', 'Ten minutes later', { expires: '10m' }); 14setCookie('stringSuffixs', 'Thirty seconds later', { expires: '30s' });
Alias: setRawCookie
Set a cookie without encoding.
Alias: removeCookie
Remove a cookie on the current domain. If you want to remove the parent domain's cookie, you can use the options
parameter, such as remove('cookieName', { domain: 'parentdomain.com' })
.
You can write your cookie get and set methods with JSON support easily:
1import { getCookie, setCookie } from 'tiny-cookie'; 2 3export const getJSON = (key) => getCookie(key, JSON.parse); 4export const setJSON = (key, value, options) => setCookie(key, value, JSON.stringify, options);
MIT.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
Found 1/27 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
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
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
19 existing vulnerabilities detected
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