cookie.js
419 Bytes
/**
* 获取 UID
* @param {[object]} req
* @return {[string]}
*/
exports.getUid = (req) => {
var _uid = 0,
cookie = req.cookies._UID,
cookieList;
if (req.isApp) {
return req.query.uid || 0;
}
if (cookie) {
cookieList = cookie.split('::');
if (cookieList[1] && !isNaN(cookieList[1])) {
_uid = cookieList[1];
}
}
return _uid;
};