Authored by 陈峰

add comment

... ... @@ -88,7 +88,7 @@ app.use((req, res, next) => {
let isSpider = /spider/i.test(req.get('User-Agent') || '');
if (config.aliasDomains.some(d => d === req.hostname) || isSpider) {
console.log('close session');
// 如果是非m.yohobuy.com域名(无法设置sessionid到cookie域名不同)且是爬虫访问,session降级使用cookiesession
req.session = {
degrage: true
};
... ... @@ -126,7 +126,6 @@ app.use(compression());
require('./doraemon/middleware/yoho-session')(app);
app.use((req, res, next) => {
console.log(req.session);
req.user = {}; // 全局的用户数据
req.yoho = {}; // req和res绑定yoho对象,用于传递全局数据, 如req.yoho.channel等
req.app.locals.wap = app.locals.wap; // zookeper对象赋值
... ...
... ... @@ -21,6 +21,7 @@ function yohoSession(opts) {
opts.backSession = opts.backSession || 'session2';
if (req.session && !req.session.degrage && !notUseRedis) {
// 如果存在session并且没有被降级,且移除redis开关没开,则继续使用session redis
req.sessionError = false;
} else {
// 重建 session
... ...