1.0.15 • Published 1 year ago

simple-cookie v1.0.15

Weekly downloads
578
License
MIT
Repository
github
Last release
1 year ago

simple-cookie

simple cookie serializer & parser for node.js

NPM Version

install

npm install simple-cookie

usage

var cookie = require('simple-cookie');

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

What is cookieObject:

name String : cookie name

value String : cookie value

expires DateString | Number | Date (optional) : expire date (default type is Date), value will be used as a parameter in new Date. e.g. new Date(yourDateString).

path String (optional) : cookie path, defaults to /

domain String (optional) : cookie domain

httponly Boolean (optional) : defaults to false

secure Boolean (optional) : defaults to false

samesite String : samesite

##methods

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


cookie.parse( cookieString  [, defaultPath]  [, defaultDomain]  );
// will create object like the 'cookieObject'


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

cheers,

jujiyangasli.com

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

4 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago

0.0.8

9 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago

0.0.0

10 years ago