与www和非www的Nodejs会话问题

我有以下的条件

(1)如果我访问https://example.com如果去login页面。

(2)同样如果我访问https://www.example.com它去login页面

现在我从https://example.comlogin,redirect到仪表盘页面,这很好。 并再次当我访问https://example.com它redirect到仪表板页面。

现在问题,当我访问https // www.example.com它redirect到login页面。

这意味着我可以login两个会话

1) https://example.com 2) https://www.example.com在同一浏览器上。 ?

如何处理这个请。

我也使用httpredirect。

http.createServer(function (req, res) { res.writeHead(301, { "Location": "https://www." + req.headers['host'] + req.url }); res.end(); }).listen(80); var secureServer = https.createServer(sslOptions,app).listen(443, function(err,result){ console.log("Express server listening on port : 443"); console.log("Mode : " + app.get('mode')); }); 

有什么build议么 ?

谢谢

只是不要在多个主机名上托pipe您的网站。 挑一个是规范和redirect(与一个301 HTTP响应)从另一个到它的所有请求。