1.0.2 • Published 3 years ago

@etherio/etherio-cookie v1.0.2

Weekly downloads
1
License
MIT
Repository
github
Last release
3 years ago

etherio-cookie

Installation

    npm install etherio-cookie

Usage

//* importing module
const cookie = require('etherio-cookie');

Parse Cookie From String

var cookies = cookie.parse(request.headers.cookie);

or

var cookies = cookie.parse('<cookie-name>=<cookie-value>;<more-cookie>=<more-value>');

Create/Set Cookie

// if u want to add setHeader(cookie) on response, add response variable in second argument
cookies.add({
    name: 'string:required',
    value: 'string:required',
    expires: new Date,
    secure: false,
    httponly: false,
    domain: '*',
    path: '/',
    samesite: 'Las'
}, response);

or

cookie.create({
    name: 'string:required',
    value: 'string:required',
    expires: new Date,
    secure: false,
    httponly: false,
    domain: '*',
    path: '/',
    samesite: 'Las'
});