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

前端 未结 5 1267
甜味超标
甜味超标 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 01:37

    Your code looks pretty solid, but is there a reason you're using client.end()? It forcibly closes the redis connection and is not clean. I don't think you need it at all:

    https://github.com/mranney/node_redis/issues/74

    I am not sure about the underlying architecture for connect-redis, but I'm wondering if calling client.end is what's resetting your sessions. What happens if you take those out?

提交回复
热议问题