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

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

    Surely you need to save that session in some way, this might work.

    req.session.regenerate(function(){
        req.session.username = username.toString();
        res.redirect('/home');
    });
    

提交回复
热议问题