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

前端 未结 5 1196
甜味超标
甜味超标 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:56

    Alright, I found the solution. The problem is that the time in maxAge was added to the current date. So, in the browser side, the cookie was set to expire at the GMT time shown.

    The problem was the following : I use a virtual machine to test node.js, and, you know... sometimes, you suspend your machine.

    Well, what happened is that the machine's time was two days late. So, whenever the cookie was set on the server side, the client side thought the cookie was already expired, since my host machine was not two days late.

    Another stupid outcome.

提交回复
热议问题