express-session-id

2.0.5 • Public • Published

express-session-id

Generated with nod NPM version Build Status Coverage Status

An express middleware for session ID. Mainly Used for analytics session tracking.

Install

$ npm install --save express-session-id

Usage

import sessionId from 'express-session-id';
import express from 'express';
import cookieParser from 'cookie-parser';
 
const app = express();
app.use(cookieParser('my secret key'));
app.use(sessionId({
  idleTime: 10 * 1000 * 60, // 10 minutes
  cookie: {
    signed: true
  }
}))
 
app.get('/', (req, res) => {
  console.log(req.sessionID);
  /*
    Rest of the code
  */
});

API

Table of Contents

sessionId

This function return a session id middleware. The session id is placed at req.sessionID

Parameters

  • options object (optional, default {})
    • options.idleTime number max idle time before destoying a session. env: SESSION_ID_IDLE_TIME (optional, default (30*1000*60))
    • options.name string Name of the cookie. env: SESSION_ID_NAME (optional, default s_id)
    • options.genId function function to generate id's. see uuid/v4 (optional, default uuid/v4)
    • options.cookie object config to pass to cookies. see cookie (optional, default {})

License

MIT © Daniel Reisel

Readme

Keywords

Package Sidebar

Install

npm i express-session-id

Weekly Downloads

2

Version

2.0.5

License

MIT

Unpacked Size

7.9 kB

Total Files

6

Last publish

Collaborators

  • dreisel