Authored by xuhongyun

支持将登录时返回的phpsession保存到cookie中

@@ -9,6 +9,18 @@ module.exports=function(app) { @@ -9,6 +9,18 @@ module.exports=function(app) {
9 9
10 app.post("/login", "common_login", function (login, req, res){ 10 app.post("/login", "common_login", function (login, req, res){
11 if (login.code == 200) { 11 if (login.code == 200) {
  12 + if (req.session.gray) {
  13 + // 登录成功后,将phpsession保存下来
  14 + var gray_cookie = req.session.gray.replace(/[\[|\]]/g, '').split(';');
  15 + gray_cookie.forEach(function (n) {
  16 + console.log(n);
  17 + var item = n.split("=");
  18 + if (item.length > 1 && item[0] == "PHPSESSID") {
  19 + res.cookie(item[0], item[1], { maxAge: 7200000, httpOnly: true });
  20 + }
  21 + });
  22 + res.cookie('domain', '.yohobuy.com', { maxAge: 7200000, httpOnly: true });
  23 + }
12 res.myRedirect('/'); 24 res.myRedirect('/');
13 } else { 25 } else {
14 res.myRedirect('/login'); 26 res.myRedirect('/login');