我正在使用jsonwebtoken而且我想在每个请求中传递此令牌 .

我是否在会话中设置了令牌并使用令牌 app.use 传递会话?

或者我必须将其存储在Cookie中?

我可以通过JWT检索已登录的用户吗?

我创建了令牌

var token = jwt.sign(user, app.get('superSecret'), {
                    expiresIn: 1440 // expires in 24 hours
                });

并检查令牌

jwt.verify(token, app.get('superSecret'), function(err, decoded) {
                if (err) {
                    return res.json({ success: false, message: 'Failed to authenticate token.' });
                } else {
                    // if everything is good, save to request for use in other routes
                    req.decoded = decoded;
                    next();
                }
            });