Authored by ccbikai(👎🏻🍜)

恢复代码

@@ -104,22 +104,22 @@ app.use(cookieSession({ @@ -104,22 +104,22 @@ app.use(cookieSession({
104 })); 104 }));
105 105
106 app.use((req, res, next) => { 106 app.use((req, res, next) => {
107 - // if (req.session) {  
108 - // let sessionKeys = Object.keys(req.session || {});  
109 - // let backSessionKeys = Object.keys(req.session2.sessionBack || {});  
110 -  
111 - // if (backSessionKeys.length > sessionKeys.length) {  
112 - // let differences = _.difference(backSessionKeys, sessionKeys);  
113 -  
114 - // _.forEach(differences, d => {  
115 - // req.session[d] = req.session2.sessionBack[d];  
116 - // });  
117 - // }  
118 - // req.session2.sessionBack = req.session;  
119 - // } else {  
120 - // req.session = new memcachedSession.Session(req);  
121 - // req.session = _.assign(req.session, req.session2.sessionBack);  
122 - // } 107 + if (req.session) {
  108 + let sessionKeys = Object.keys(req.session || {});
  109 + let backSessionKeys = Object.keys(req.session2.sessionBack || {});
  110 +
  111 + if (backSessionKeys.length > sessionKeys.length) {
  112 + let differences = _.difference(backSessionKeys, sessionKeys);
  113 +
  114 + _.forEach(differences, d => {
  115 + req.session[d] = req.session2.sessionBack[d];
  116 + });
  117 + }
  118 + req.session2.sessionBack = req.session;
  119 + } else {
  120 + req.session = new memcachedSession.Session(req);
  121 + req.session = _.assign(req.session, req.session2.sessionBack);
  122 + }
123 123
124 if (!req.sessionID) { 124 if (!req.sessionID) {
125 req.sessionID = uuid.v4(); 125 req.sessionID = uuid.v4();
@@ -19,9 +19,6 @@ module.exports = () => { @@ -19,9 +19,6 @@ module.exports = () => {
19 req.user.uid = cookie.getUid(req); 19 req.user.uid = cookie.getUid(req);
20 } 20 }
21 21
22 - console.log('======', req.session)  
23 - console.log('======', req.user)  
24 -  
25 next(); 22 next();
26 }; 23 };
27 }; 24 };