cookies-utils
This project contains functions to help manage cookies.
Installation
NPM
Install the library with npm install cookies-utils
.
CDN
Or use it directly in your browser via jsDelivr or unpkg:
... cookiesUtils.deleteCookie('name')
or
... cookiesUtils.deleteCookie('name')
Usage
Set a cookie
; // more information about the options in documentation https://developer.mozilla.org/en-US/docs/Web/API/Document/cookieconst cookieOptions = name: "name" // string, value: "value" // string, maxAge: 10 * 60 // optional number (value in seconds), expires: 2099 10 1 // optional Date, path: "/path" // optional string, domain: "site.com" // optional string, secure: true // optional boolean, sameSite: "lax" // optional enum 'lax' | 'strict' | 'none';;
Check existence of cookie
; const isExist = ;
Delete a cookie
; ;
Check if cookie has specific value
; const hasValue = ;
Delete all cookies
; ;