0

I've noticed noticed that when I restart my Express server, the session id saved on the browser is updated to a new value. Is this normal behavior? Is this something I can configure?

These are my current express-session options:

var sessionOptions = {
  secret: "secret_here",
  resave: false,
  saveUninitialized: true,
  cookie: {
    maxAge: 86400000
  }
}
spencer.sm
  • 19,173
  • 10
  • 77
  • 88

1 Answers1

0

As stated in the docs:

Each session has a unique ID associated with it.

You can override the function that generates the ID by setting the genid property.

app.use(session({
  genid: function(req) {
    return genuuid() // use UUIDs for session IDs
  },
  secret: 'keyboard cat'
}))