@amphibian/write-cookie

1.1.0 • Public • Published

write-cookie

build status

write browser cookie

npm install @amphibian/write-cookie

Arguments

name String

Cookie name.

value String

Cookie value. Will be URL encoded.

options Object

Options for setting the cookie.

  • expiration Date: Cookie expiration date. 1 year from now is the default.
  • domain String: Cookie domain. Current hostname without subdomains is the default, eg. npmjs.org.
  • path String: Cookie path. / is the default.

Example

var writeCookie = require('@amphibian/write-cookie');

// By default, cookies live for a year.
writeCookie('test_cookie', 'test_value');

// This can be overridden using `options`
writeCookie('test_cookie2', 'test_value2', {
    expiration: new Date((new Date()).getTime() + (1000 * 60 * 60)) // 1 hour
});

// By default, the cookie domain is set to the current hostname without
// subdomains included. Override this using the `domains` option
writeCookie('test_cookie3', 'test_value3', {
    domains: 'my-domain.com'
});

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i @amphibian/write-cookie

      Weekly Downloads

      3

      Version

      1.1.0

      License

      ISC

      Unpacked Size

      9.34 kB

      Total Files

      6

      Last publish

      Collaborators

      • thomaslindstr_m