cjihrig / thin-mint

HTTP cookie utility
MIT License
1 stars 0 forks source link

thin-mint

Current Version Build Status via Travis CI Dependencies belly-button-style

HTTP cookie utility. thin-mint provides parsing and stringification of individual HTTP cookies.

Example

var ThinMint = require('thin-mint');
var str = 'foo=bar; domain=continuation.io; path=/baz; expires=Sun, 20 Mar 2016 07:05:03 GMT; max-age=1234; secure; httponly';
var cookie = new ThinMint(str);

/*
cookie = {
  name: 'foo',
  value: 'bar',
  domain: 'continuation.io',
  path: '/baz',
  secure: true,
  httpOnly: true,
  expires: 1458457503000,
  maxAge: 1234,
  expiration: 1441772074919,
  input: {
    cookie: 'foo=bar; domain=continuation.io; path=/baz; expires=Sun, 20 Mar 2016 07:05:03 GMT; max-age=1234; secure; httponly',
    name: 'foo',
    value: 'bar',
    domain: 'continuation.io',
    path: '/baz',
    secure: 'secure',
    httpOnly: 'httponly',
    expires: 'Sun, 20 Mar 2016 07:05:03 GMT',
    maxAge: '1234'
  }
}
*/

console.log(cookie.toString());

Methods

Cookie(cookieStr) Constructor

Cookie.prototype.toRequestCookie()

Converts the Cookie into a request cookie string.

Cookie.prototype.toString()

Creates a string representation of the Cookie object.