Languages

Express.js - express-session deprecated warning

3 points
Asked by:
Mikolaj
519

I express-session package deprecated? I keep getting the warning below, but all seems to be working good.

Stack trace:

$ node index.js
express-session deprecated undefined resave option; provide resave option index.js:6:5
express-session deprecated undefined saveUninitialized option; provide saveUninitialized option index.js:6:5

My code:

app.use(
    session({
        secret: 'session-secret-here',
        cookie: { maxAge: 1000 * 60 * 60 * 24 * 7 },
    })
);

I am using express-session 1.17.3

1 answer
3 points
Answered by:
Mikolaj
519

No, express-session is not deprecated. You just need to specify the resave and saveUninitialized options as the warning says.

Practical example

app.use(
    session({
        secret: 'session-secret-here',
        cookie: { maxAge: 1000 * 60 * 60 * 24 * 7 },
        resave: false,
        saveUninitialized: true,
    })
);

 

References

  1. Express session middleware
0 comments Add comment
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join