express-session-id
v2.0.5
Published
An express middleware for session ID
Downloads
17
Readme
express-session-id
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, defaults_id
)options.genId
function function to generate id's. see uuid/v4 (optional, defaultuuid/v4
)options.cookie
object config to pass to cookies. see cookie (optional, default{}
)
License
MIT © Daniel Reisel