Express change session every request

后端 未结 5 1843
夕颜
夕颜 2021-02-11 01:52

I have a function to login

app.post(\'/doLogin\', function(req,res){
        db.users.findOne({username: req.body.username}, function(err, user) {
            if         


        
5条回答
  •  生来不讨喜
    2021-02-11 02:18

    The best way to do things is to always let Express deal with it, if it can.

    https://flaviocopes.com/express-sessions/ ( Updated Session tutorial although links should not be considered answers )

    There's a link that can show you how to set up redis for sessions in Express. You shouldn't have to even query redis yourself when dealing with sessions, that's a job for middleware in node.

提交回复
热议问题