sgmonda
sgmonda

Reputation: 2719

Distributed session storage in ExpressJS

I'm working on a distributed web app, and I want to use ExpressJS session to store data, so I need a distributed session storage. Alternatively, I could build my own session storage, but I don't know how to do it.

I'm using memcached (by mean of this module) in some parts of the project different from the web app, so it could be nice to be able to use memcached as session storage.

I want something like this:

app.use(express.session({secret: 'something', store: new MemcachedStorage(...)}));

So what storage should I use?

Upvotes: 0

Views: 1322

Answers (2)

Floby
Floby

Reputation: 2336

You're probably looking for https://github.com/balor/connect-memcached. This connect module (connect is an underlying layer of express) is used to store your session in memcached.

Upvotes: 1

Puigcerber
Puigcerber

Reputation: 10104

I think this is what you are looking for:

app.use(express.session({ 
  secret: 'CatOnTheKeyboard', 
  store: new MemcachedStore 
}));

Upvotes: 6

Related Questions