Socket
Socket
Sign inDemoInstall

cookie-manager

Package Overview
Dependencies
18
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    cookie-manager

cookie manager for any http client in node.js


Version published
Weekly downloads
725
decreased by-29.68%
Maintainers
1
Install size
170 kB
Created
Weekly downloads
 

Readme

Source

#cookie-manager

cookie manager for any http client in node.js

##install

npm install cookie-manager

##Usage

var CM = require('cookie-manager');
var cm = new CM();

###Storing Cookies

// Hey, i just requested https://example.com/is/cool
// the website sent me some cookies to set. please store these cookies...
//

cm.store( 
	'https://example.com/is/cool', 
	'cname=cval; Expires=someDate; domain=.example.com; path=/' 
);

cm.store( 
 'https://example.com/is/cool', 
 [
  'cnameSecure=cval1sec; Expires=someDate; domain=.example.com; path=/; secure',
  'cnameHttpOnly=cval1Http; Expires=someDate; domain=.example.com; path=/; HttpOnly',
  'cnameWWW=cvalWWW; Expires=someDate; domain=www.example.com; path=/something'
 ]
);

###Prepare Cookies for request

// Hey, i want to browse http://example.com/ Please prepare the cookies
cookies = cm.prepare( 'http://example.com' );
// 'cname=cval; cnameHttpOnly=cval1Http'
// Hey, i want to browse http://cool.example.com/ Please prepare the cookies
cookies = cm.prepare( 'http://cool.example.com' );
// 'cname=cval; cnameHttpOnly=cval1Http'
// Hey, i want to browse http://www.example.com/something/awesome Please prepare the cookies
cookies = cm.prepare( 'http://www.example.com/something/awesome' );
// 'cname=cval; cnameHttpOnly=cval1Http; cname2=cval2'
// Hey, i'm trying to request https://www.example.com/something/awesome
cookies = cm.prepare( 'https://www.example.com/something/awesome' )
// 'cname=cval; cnameSecure=cval1sec; cnameHttpOnly=cval1Http; cname2=cval2'
// Hey, i want to browse http://www.example.com/other/stuff Please prepare the cookies
cookies = cm.prepare( 'http://www.example.com/other/stuff' );
// 'cname=cval; cnameHttpOnly=cval1Http'

###For Browser emulation

this.document.cookie = cm.prepare( 
							'http://www.example.com/something/awesome', 
							true 
						);

// cname=cval; cname2=cval2

###For Time Travelers

// Hey, i traveled 500 years in time, 
// and i want to browse http://www.example.com/something/awesome
// again.
//
cm.prepare( 'http://www.example.com/something/awesome' );
// empty string.. the cookies have expired.

cheers,

jujiyangasli.com

Keywords

FAQs

Last updated on 25 Oct 2017

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc