...
|
...
|
@@ -76,6 +76,13 @@ app.use(bodyParser.urlencoded({ |
|
|
app.use(cookieParser());
|
|
|
app.use(compression());
|
|
|
|
|
|
const sessionStore = new MemcachedStore({
|
|
|
hosts: config.memcache.session,
|
|
|
prefix: 'yohobuy_session:',
|
|
|
reconnect: 5000,
|
|
|
timeout: 1000,
|
|
|
retries: 0
|
|
|
});
|
|
|
app.use(memcachedSession({
|
|
|
proxy: true,
|
|
|
resave: false,
|
...
|
...
|
@@ -87,20 +94,14 @@ app.use(memcachedSession({ |
|
|
domain: 'yohobuy.com',
|
|
|
httpOnly: false
|
|
|
},
|
|
|
store: new MemcachedStore({
|
|
|
hosts: config.memcache.session,
|
|
|
prefix: 'yohobuy_session:',
|
|
|
reconnect: 5000,
|
|
|
timeout: 1000,
|
|
|
retries: 0
|
|
|
})
|
|
|
store: sessionStore
|
|
|
}));
|
|
|
|
|
|
app.use(cookieSession({
|
|
|
requestKey: 'session2',
|
|
|
cookieName: 'yohobuy_session_cookie',
|
|
|
secret: '82dd7e724f2c6870472c89dfa43cf48d',
|
|
|
domain: config.cookieDomain
|
|
|
domain: 'yohobuy.com'
|
|
|
}));
|
|
|
|
|
|
app.use((req, res, next) => {
|
...
|
...
|
@@ -118,6 +119,10 @@ app.use((req, res, next) => { |
|
|
req.session2.sessionBack = req.session;
|
|
|
} else {
|
|
|
req.session = new memcachedSession.Session(req);
|
|
|
req.session.cookie = new memcachedSession.Cookie({
|
|
|
domain: 'yohobuy.com',
|
|
|
httpOnly: false
|
|
|
});
|
|
|
req.session = _.assign(req.session, req.session2.sessionBack);
|
|
|
}
|
|
|
|
...
|
...
|
@@ -177,6 +182,6 @@ try { |
|
|
}
|
|
|
|
|
|
// listener
|
|
|
app.listen(config.port, function() {
|
|
|
app.listen(config.port, function () {
|
|
|
logger.info('yohobuy start');
|
|
|
}); |
...
|
...
|
|