if(req.session.curruser){ console.log(req.session.curruser); // { username: ‘mrlog2’, groupid: 1, groupname: ‘杭州某某公司’ } res.locals.curruser = req.session.curruser; //这个出错。提示如下。 };
/Users/rmbp-mrlong/code/node.js/wechatdeve/src/node_modules/express-session/session/memory.js:80 self.sessions[sid] = JSON.stringify(sess);
TypeError: Converting circular structure to JSON at Object.stringify (native) at Object._onImmediate (/Users/rmbp-mrlong/code/node.js/wechatdeve/src/node_modules/express-session/session/memory.js:80:31) at processImmediate [as _immediateCallback] (timers.js:330:15)
JSON里对象’指针’转圈了。
在前面加上 console.log(req.session)
看看 req.session
里面的数据都是什么样的
req.session 就一个数据 curruser