JavaScript-utilities to handle cookies everywhere
MIT License
JavaScript-utilities to handle cookies everywhere.
npm install @yurkimus/cookies
"@yurkimus/cookies": "npm:@yurkimus/cookies"
"@yurkimus/cookies": "github:yurkimus/cookies"
"@yurkimus/cookies": "https://raw.githubusercontent.com/yurkimus/cookies/main/source/index.js"
parseCookie :: string -> *
parseCookie('name=John; age=30; role=admin') // => [['name', 'John'], ['age', '30'], ['role', 'admin']]
readCookie :: * -> string -> *
let cookie = 'name=John; age=30; role=admin'
readCookie('age', cookie) // => '30'
readCookie(['age', 'name'], cookie) // => ['30', 'John']
serializeCookie :: string -> * -> [(string, string)] -> string
let attributes = [
['path', '/'],
['expires', 'Wed, 21 Oct 2026 07:28:00 GMT'],
]
serializeCookie('name', 'John', attributes) // => 'name=John; path=/; expires=Wed, 21 Oct 2026 07:28:00 GMT'