Skip to main content

Built and signed on GitHub Actions

Simple cookie parser & serializer

This package works with Bun, Cloudflare Workers, Node.js, Deno, Browsers
JSR Score
100%
Published
a month ago (2.0.8)

Simple cookie parser & serializer

Examples

Usage


import {
 type CookieObject,
 stringify, parse, tokenize
} from '@juji/simple-cookie';

const cookieObject = {
	name: 'cookieName',
	value: 'cookie value',
	expires: (new Date()).valueOf() + 500000,
	path: '/',
	domain: 'domain.com',
	httponly: false,
	secure: true,
	samesite: 'None'
}

const cookie: string = stringify( cookieObject );
// cookieName=cookie%20value; Expires: Sat, 15-Aug-2015 17:41:05 GMT; Max-Age: 31449600; Path=/; domain=domain.com; secure; samesite=None


const cookieObject: CookieObject = parse( cookieString  [, defaultPath]  [, defaultDomain]  );
// will create object like the 'cookieObject'


const tokens: string = tokenize([
	{name:'cookie1', value: 'cvalue1'},
	{name:'cookie2', value: 'cvalue2'},
	{name:'cookie3', value: 'cvalue3'}
]);
// cookie1=cvalue1; cookie2=cvalue2; cookie3=cvalue3

checkout the SameSite attribute.

Built and signed on
GitHub Actions
View transparency log

Add Package

deno add @juji/simple-cookie

Import symbol

import * as mod from "@juji/simple-cookie";

Add Package

npx jsr add @juji/simple-cookie

Import symbol

import * as mod from "@juji/simple-cookie";

Add Package

yarn dlx jsr add @juji/simple-cookie

Import symbol

import * as mod from "@juji/simple-cookie";

Add Package

pnpm dlx jsr add @juji/simple-cookie

Import symbol

import * as mod from "@juji/simple-cookie";

Add Package

bunx jsr add @juji/simple-cookie

Import symbol

import * as mod from "@juji/simple-cookie";