1
我使用redirect
通过当前用户的用户名至其他网页的价值,所以......如何更改HTML标题
var current_user = encodeURIComponent(req.body.log_username);
res.redirect('/home?valid=' + current_user);
...接收页面有以下代码...
router.get('/', function (req, res) {
res.render('home', { title: 'Express' });
var passedVariable = req.query.valid;
console.log(passedVariable);
});
正确的用户名已通过,但我需要知道如何将用户名并入我的html。
例如,当HTML呈现,我想报头说"Welcome 'username'"
我怎样才能做到这一点?使用php这是相对简单的,但我对节点js的损失。
为什么不使用实际的服务器端会话和存储用户信息的方式?坚持(会话)数据就像你所建议的那样*可能是危险的。 – mscdex