simple-cookie
simple cookie serializer & parser for node.js
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
}
What is cookieObject
:
name String
: cookie name
value String
: cookie value
expires DateString | Number | Date
(optional) : expire date (default type is Date)
path String
(optional) : cookie path, defaults to /
domain String
(optional) : cookie domain
httponly Boolean
(optional) : defaults to false
secure Boolean
(optional) : defaults to false
##methods
var cookieString = cookie.stringify( cookieObject );
cookie.parse( cookieString [, defaultPath] [, defaultDomain] );
cookie.tokenize([
{name:'cookie1', value: 'cvalue1'},
{name:'cookie2', value: 'cvalue2'},
{name:'cookie3', value: 'cvalue3'}
]);
cheers,
jujiyangasli.com