Node.js - Session doesn't persist through res.redirect()

前端 未结 5 1192
甜味超标
甜味超标 2021-02-09 01:37

I\'m (almost) successfully using Node.js with Express and Redis to handle sessions.

The problem I\'m having is that the session is not kept when I use res.redirect

5条回答
  •  余生分开走
    2021-02-09 02:01

    I was having a similar problem in that I was setting something on the session that was not persisting outside the app.get() it was set in.

    My problem turned out to be that I was not doing a res.redirect() at the end of my app.get(). Looks like I was setting something on a request object and then allowing it to get garbage collected.

    I added a res.redirect( '/nextmethod' ) and the data persists just fine.

提交回复
热议问题