
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Sesame is a session middleware for express/connect for amazingly simple
sessions. To update sessions, just modify req.session.
var connect = require('connect');
var webserver = connect.createServer();
webserver.use(require('sesame')());
webserver.use(connect.router(function (app) {
app.get('/', function (req, res) {
req.session.times = (req.session.times || 0) + 1;
res.writeHead(200, { 'Content-Type' : 'text/plain' });
res.end(req.session.times + ' times!');
});
}));
console.log('Listening on 9090');
webserver.listen(9090);
Run this program and it will repeatedly increment a counter. Woo! However!
When you restart the above server or when it crashes you'll lose all of your sessions! Never fear, with sesame it's super easy to persist sessions across restarts! Just swap out
webserver.use(require('sesame')());
with this to use nStore:
webserver.use(require('sesame')({
store : require('nStore')(__dirname + '/nstore.db')
}));
or if you want to use supermarket:
webserver.use(require('sesame')({
store : new(require('supermarket'))({
filename : __dirname + '/supermarket.db', json : true,
})
}));
or if you'd like to use chaos
webserver.use(require('sesame')({
store : require('chaos')(__dirname + '/chaos.db').mount('sessions')
}));
If your favorite database backend isn't listed you should send me a pull request!
Check out the examples/ directory for more examples.
Options can be:
store - the storage engine to use
cookieName - the cookie name to use, defaults to session_id
sessions - the sessions to start with if you'd rather load them yourself
Sesame adds session, sessions, and sessionID to the req object.
You can modify req.sessions[req.sessionID] just the same as req.session.
If you assign a new value to req.session like this:
req.session = { x : 55 };
it will also just work, even when using a persistent store.
To empty the session, just do:
req.session = {}
Easy!
Wait a moment! How can you just throw a database at this AND modify deeply
nested elements in req.session, you may be asking yourself?
Under the hood, harmony proxies trap updates to the req.session object to keep
the sessions on disk in sync with the in-memory sessions.
FAQs
Session middleware for lazy people.
The npm package sesame receives a total of 8 weekly downloads. As such, sesame popularity was classified as not popular.
We found that sesame demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.