Skip to content

Latest commit

 

History

History
53 lines (42 loc) · 1.26 KB

README.md

File metadata and controls

53 lines (42 loc) · 1.26 KB

mongoose-store Build Status

Mongoose session store for Express

Installation

$ npm install mongoose-store --save

Usage

Options

  • url: The URL connection format mongodb://user:pass@host:port/database/collection. Only need it if there is no connection yet.
  • ttl (seconds): How long the session persist on the database.

Example

var express       = require('express');
var session       = require('express-session');
var MongooseStore = require('mongoose-store')(session);

var app = express();

var mongooseStore = new MongooseStore({
  url: 'mongodb://127.0.0.1:27017/testing',
  ttl: 600
});

app.use(session({
  name: 'app.sid',
  secret: 'yoursecret',
  store: mongooseStore
}));

With replica set:

var express       = require('express');
var session       = require('express-session');
var MongooseStore = require('mongoose-store')(session);

var app = express();

var mongooseStore = new MongooseStore({
  url: 'mongodb://ip1:27017/testing,mongodb://ip2:27017/testing,mongodb://ip3:27017/testing',
  ttl: 600
});

app.use(session({
  name: 'app.sid',
  secret: 'yoursecret',
  store: mongooseStore
}));