You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

cookie-getter

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cookie-getter

Super light, high performance clientside cookie reader module.

2.0.0
latest
Source
npm
Version published
Weekly downloads
179
-43.35%
Maintainers
2
Weekly downloads
 
Created
Source

Minimalist (<10 LOC), performant, clientside cookie reader module and nothing else. It is tolerant of being required server-side. It will simply returns null if called within node.

Dead simple function that has the best performance according to: http://jsperf.com/cookie-parsing

Handy to have as a separate module for easy installation with npm.

Usage

installing:

npm install cookie-getter

using:

var cookies = require('cookie-getter');

// returns the value of the cookie if it's just a simple string
var username = cookies('username');

// if the cookie is a JSON string it will parse it as well
user = cookies('user');

console.log(user.firstName); // logs out name of firstName value if encoded as JSON in cookie.

License

MIT

Keywords

client

FAQs

Package last updated on 16 Feb 2017

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