Authored by ccbikai(👎🏻🍜)

test

... ... @@ -87,9 +87,9 @@ app.use(MemcachedSession({
domain: 'yohobuy.com',
httpOnly: false
},
genid() {
return uuid.v4() // use UUIDs for session IDs
},
// genid() {
// return uuid.v4() // use UUIDs for session IDs
// },
store: new MemcachedStore({
hosts: config.memcache.session,
prefix: 'yohobuy_session:',
... ... @@ -99,38 +99,38 @@ app.use(MemcachedSession({
})
}));
app.use(CookieSession({
requestKey: 'session2',
cookieName: 'yohobuy_session_cookie',
secret: '82dd7e724f2c6870472c89dfa43cf48d',
domain: config.cookieDomain
}));
app.use((req, res, next) => {
if (req.session) {
let sessionKeys = Object.keys(req.session || {});
let backSessionKeys = Object.keys(req.session2.sessionBack || {});
if (backSessionKeys.length > sessionKeys.length) {
let differences = _.difference(backSessionKeys, sessionKeys);
_.forEach(differences, d => {
req.session[d] = req.session2.sessionBack[d];
});
}
req.session2.sessionBack = req.session;
} else {
req.session = new MemcachedSession.Session(req);
req.session = _.assign(req.session, req.session2.sessionBack);
}
if (typeof req.session.reset !== 'function') {
req.session.reset = function() {
req.session.destroy();
req.session2.reset();
};
}
next();
});
// app.use(CookieSession({
// requestKey: 'session2',
// cookieName: 'yohobuy_session_cookie',
// secret: '82dd7e724f2c6870472c89dfa43cf48d',
// domain: config.cookieDomain
// }));
// app.use((req, res, next) => {
// if (req.session) {
// let sessionKeys = Object.keys(req.session || {});
// let backSessionKeys = Object.keys(req.session2.sessionBack || {});
// if (backSessionKeys.length > sessionKeys.length) {
// let differences = _.difference(backSessionKeys, sessionKeys);
// _.forEach(differences, d => {
// req.session[d] = req.session2.sessionBack[d];
// });
// }
// req.session2.sessionBack = req.session;
// } else {
// req.session = new MemcachedSession.Session(req);
// req.session = _.assign(req.session, req.session2.sessionBack);
// }
// if (typeof req.session.reset !== 'function') {
// req.session.reset = function() {
// req.session.destroy();
// req.session2.reset();
// };
// }
// next();
// });
app.use((req, res, next) => {
... ...
... ... @@ -235,7 +235,7 @@ const local = {
})(req, res, next);
},
logout: (req, res) => {
req.session.reset();
req.session.destroy();
res.clearCookie('_UID', {
domain: 'yohobuy.com'
... ...