when should I use cookie-parser with express-session?

后端 未结 2 1028
再見小時候
再見小時候 2021-02-02 06:54

In most ExpressJs example, I found using cookie-parser with express-session.

If I could access session data with req.session.name

2条回答
  •  别跟我提以往
    2021-02-02 07:46

    For future humble coders, that will stumble upon this - I'm posting an up-to-date answer:

    As the official description of express-session middleware says here: express-session

    Since version 1.5.0, the cookie-parser middleware no longer needs to be used for this module to work. This module now directly reads and writes cookies on req/res. Using cookie-parser may result in issues if the secret is not the same between this module and cookie-parser.

    Therefore, just use express-session middleware and have a nice day.

提交回复
热议问题