Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cookiestorage

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cookiestorage

Browserify-compatible module to get and set cookies in the browser using Storage API

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
50
increased by25%
Maintainers
1
Weekly downloads
 
Created
Source

cookiestorage

Build Status

Manage document.cookie using the Storage API.

NOTE: originally a fork of cookie-monster, itself a fork of cookie-cutter.

install

npm install cookiestorage

api

var cookieStorage = require('cookiestorage');
var cookie = cookieStorage(document);

cookieStorage(document)

Return a new cookie object with .getItem() and .setItem() operating on document.

The provided document should have a non-referentially transparent cookie property like the DOM's variant where assignment with optional path and expiry creates a new cookie in the getter as a key=value pair.

If document is not provided, uses the global document if it exists. Otherwise, creates a new plain object {cookie:''}.

If given a string, uses { cookie: givenString }.

#length

Returns number of key/value pairs present in document.cookie

#getItem(key)

Returns the cookie value for key.

#setItem(key, value, options={})

Sets the cookie at key to value with additional options:

  • expires: Will be parsed by new Date(expires) which accepts String formatted per RFC 2822 or ISO-8601, Number of milliseconds since 1 January 1970 00:00:00 UTC (Unix Epoch), or literal Date objects.
  • domain: see cookie documentation
  • path: see cookie documentation
  • secure: see cookie documentation

#key(index)

Returns the key (name) of the nth key/value pair in document.cookie. Order is dependent on browser implementation. May not be alphabetical, or even consistent. Use this with caution. (It is added solely for consistency with the Storage API.)

#removeItem(key)

Removes the given key from document.cookie.

#clear()

Clears document.cookie of all key/value pairs.

Keywords

FAQs

Package last updated on 03 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc