1.0.3 • Published 5 years ago

session-mongodb v1.0.3

Weekly downloads
3
License
GPL-3.0
Repository
github
Last release
5 years ago

session-mongodb

A session middleware for express stored in mongodb.
Requires cookie-parser for express.

Usage example

const express = require('express');
const app = express();
const session = require('session-mongodb');
const cookieParser = require('cookie-parser');

app.use(cookieParser());
app.use(session("mongodb://localhost/session", "VeryVeryGoodSecret", "sessionId"));

app.get('/', function (req, res){
    req.session.set('test', 'just a test');
    res.send('session.test = ' + req.session.test);
});

app.listen(3000, () => {
    console.log('Listening on 3000');
});

API

req.session.set(variableName, variableValue)

Stores the variable name with the variable value in the database. The variable name can not be 'set', 'delete' and 'destroy'

req.session.[variableName]

Returns the stored value of variableName

req.session.delete(variableName)

Deletes the value of variableName

req.session.destroy()

Destroys the session and drops it from the database

License

GPL-3.0

1.0.3

5 years ago

1.0.3-0

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago