GithubHelp home page GithubHelp logo

isabella232 / node-cookie-domain Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mantacode/node-cookie-domain

0.0 0.0 0.0 163 KB

Express middleware for dynamically setting the cookie domain.

License: MIT License

CoffeeScript 57.44% JavaScript 42.56%

node-cookie-domain's Introduction

Build Status NPM version David DM

Express middleware for wrapping res.cookie to use some sane defaults for the cookie config.

// Assuming the host is 'foo.bar.com'
var express = require('express');
var cookieDomain = require('cookie-domain');
var app = express();
app.use(cookieDomain());

/*
 *  You can also pass global overrides into cookieDomain
 *  app.use(cookieDomain({ maxAge: 86400 });
 */

app.get('/', function(req, res, next) {
  // Set a cookie using some sane defaults: { domain: '.bar.com', path: '/', maxAge: 31536000000 })
  res.cookie('a', 1);

  // Or override the defaults
  res.cookie('b', 1, { maxAge: 86400 });

  // Express will use maxAge over expires, but cookie-domain will remove maxAge and pass expires if you tell it to
  res.cookie('c', 1, { expires: false });

  // Pass false to tell cookie-domain not to pass options at all.
  res.cookie('d', 1, false);

  res.send('hello world');
});

Installation and Environment Setup

Install node.js (See download and install instructions here: http://nodejs.org/).

Clone this repository

> git clone [email protected]:mantacode/node-cookie-domain.git

cd into the directory and install the dependencies

> cd cookie-domain
> npm install && npm shrinkwrap --dev

Running Tests

Install coffee-script

> npm install coffee-script -g

Tests are run using grunt. You must first globally install the grunt-cli with npm.

> sudo npm install -g grunt-cli

Unit Tests

To run the tests, just run grunt

> grunt spec

node-cookie-domain's People

Contributors

nathangromano avatar tandrewnichols avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.