Search code examples
node.jsexpresssessionsession-variablesexpress-session

What it is the duration of stored variables in the session using express js?


For example req.session.email = mamam@ymamam.com i want to know for how long this variable will be available?


Solution

  • It depends on what values you have configured while creating that session.

    app.use(session({
      cookieName: 'session',
      duration: 30 * 60 * 1000,
      activeDuration: 5 * 60 * 1000,
    }));
    

    By Default your session variables will last till your Node get's restarted.