cookie-string
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 = ; ; // Returns 'hello=world'; // 'hello=world;domain=example.com'; // '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.