New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@wetransfer/concorde-cookie

Package Overview
Dependencies
Maintainers
5
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wetransfer/concorde-cookie

A set of tools to deal with cookies on the browser.

  • 1.6.1
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
5
Weekly downloads
 
Created
Source

npm version

Cookie module. Handy functions to deal with cookies on the browser.

Installation

npm install @wetransfer/concorde-cookie --save

Usage

In the browser

Import the package if your are using a package bundler like Webpack or Parcel:

import Cookie from '@wetransfer/concorde-cookie';

if (Cookie.get('SSID')) {
  // Do some magic!
}

Or load directly the final bundle on your browser, using a script tag. All concorde.js modules will be available in a global variable called WT:

<!-- This will load the latest version of @wetransfer/concorde-cookie module -->
<script src="https://unpkg.com/@wetransfer/concorde-cookie/dist/concorde-cookie.min.js"></script>
<script>
  WT.cookie.set('SSID', 'BBlPjuhTimjov9RCB', { secure: true });
</script>

On the server

const Cookie = require('@wetransfer/concorde-cookie');

Cookie.set('SSID', 'BBlPjuhTimjov9RCB', { secure: true });

Methods

Cookie.configure

Configure default options used when settings values for cookies. If all your cookies must present the same property, like secure, use this method before setting the cookie values.

Cookie.configure({ secure: true });
Cookie.set('foo', 'bar');
// => foo=bar; secure'

The following options can be configured:

Cookie.configure({
  // Cookie expiration date
  expires: new Date('Fri, 01 Jan 2016 09:05:12 GMT'),
  // Sets the URI to which the Cookie applies. Must be an absolute path.
  path: '/path',
  // Sets the domain to which the Cookie applies. If a domain is specified, subdomains are always included.
  domain: 'wetransfer.com',
  // Cookie to only be transmitted over secure protocol as https.
  secure:true,
});

Cookie.get

Get the value from a cookie, given a cookie name.

Cookie.get('foo');
// => 'bar'
   
// Default value in case cookies are not available or the value has not been set previously.
Cookie.get('nonexistant', { defaultValue: 1 });
// => 1
  
// If raw property is true, the value of the cookie is not decoded.
Cookie.get('bar', { raw: true });
// => 'bar%20value'

Cookie.set

Set the value for a cookie. If extra options are specified, they will override default options defined with configure method.

Cookie.set('foo', 'bar');
// => 'foo=bar'

// Set extra options for the current cookie
Cookie.set('foo', 'bar', { secure: true});
// => 'foo=bar; secure'

Cookie.unset

Unsets the value of a cookie, with null, and expires it.

Cookie.unset('foo');
// => 'foo=null; expires=Thu, 21 Dec 2017 10:57:39 GMT'

Development

In case you want to develop/debug this module while integrating with other project, please follow these steps:

  • Run npm link to create a global symlink to that module
  • Run npm run build:watch to listen to changes and rebuild the module
  • Link to this module from your project with npm link @wetransfer/concorde-cookie

Keywords

FAQs

Package last updated on 28 Feb 2019

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