Skip to content

UNMAINTAINED - Converts given key, value and options into a string that can be used for client-side cookie storage

License

Notifications You must be signed in to change notification settings

trashify/cookie-string

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

UNMAINTAINED - Converts given key, value and options into a string that can be used for client-side cookie storage

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published