Converts given key, value and options(path, domain, maxAge, expires and secure) into a string that can be used for client-side cookie storage.
$ npm install --save cookie-string
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'
Type: String
Key for the cookie to store.
Type: String
Value for the given key.
Object containing additinal options to be stored with the cookie.
Type: String
;path=path
: (e.g., '/', '/mydir')
Type: String
;domain=domain
: (e.g., 'example.com' or 'subdomain.example.com').
Type: Int
;max-age=max-age-in-seconds
: (e.g., 606024*365 or 31536000 for a year)
Type: Date
;expires=date-in-GMTString-format
: (e.g. new Date()
). Date will be implicitly converted into to UTC string format.
Type: Boolean
;secure
: Cookie to only be transmitted over secure protocol as https.
All Contributions are welcome! Please open up an issue if you would like to help out. 😄
Created with ♥ by Tiaan du Plessis. Licensed under the MIT License.