What is the session's "secret" option?

Harry picture Harry · Mar 17, 2011 · Viewed 61.5k times · Source

I don't know anything about cryptography. I'm wondering what the session secret is.

I see code like this:

app.use(express.session({
  store: mongoStore({
    url: app.set('db-uri')
  }),
  secret: 'topsecret'
}));

What is the secret and should I change it?

Answer

Hacknightly picture Hacknightly · Mar 17, 2011

Yes, you should change it. A session secret in connect is simply used to compute the hash. Without the string, access to the session would essentially be "denied". Take a look at the connect docs, that should help a little bit.