Skip to content

Latest commit

 

History

History
78 lines (42 loc) · 1.94 KB

README.md

File metadata and controls

78 lines (42 loc) · 1.94 KB

UNMAINTAINED - cookie-string Build Status XO code style npm version GitHub version

Converts given key, value and options(path, domain, maxAge, expires and secure) into a string that can be used for client-side cookie storage.

Install

$ npm install --save cookie-string

Usage

const cookieString = require('cookie-string');

cookieString('hello', 'world'); // Returns 'hello=world'
cookieString('hello', 'world', {domain: 'example.com'}); // 'hello=world;domain=example.com'
cookieString('hello', 'world', {secure: true}); // 'hello=world;secure'

API

cookieString(key, value, options)

key

Type: String

Key for the cookie to store.

key

Type: String

Value for the given key.

options

Object containing additinal options to be stored with the cookie.

path

Type: String

;path=path: (e.g., '/', '/mydir')

domain

Type: String

;domain=domain: (e.g., 'example.com' or 'subdomain.example.com').

maxAge

Type: Int

;max-age=max-age-in-seconds: (e.g., 606024*365 or 31536000 for a year)

expires

Type: Date

;expires=date-in-GMTString-format: (e.g. new Date()). Date will be implicitly converted into to UTC string format.

secured

Type: Boolean

;secure: Cookie to only be transmitted over secure protocol as https.

Contributing

All Contributions are welcome! Please open up an issue if you would like to help out. 😄

License

Created with ♥ by Tiaan du Plessis. Licensed under the MIT License.