我正在运行一个网站,但在某些浏览器(如三星浏览器和IE)上的会话存在一些问题。
在google chrome上运行正常,但是在某些浏览器上我无法保存会话。
这是应用会话
app.use(session({
cookie: {
maxAge: 60000000
},
secret: "shhhhhh",
resave: false,
name: "shhhhh",
saveUninitialized: true,
store: new MongoStore({
mongooseConnection: db
})
})
);
我有这个要求是提取的
app.post("/sendUserID", function(req, res) {
var sendUserID = function() {
req.session.userIDGuest = req.body.UserID;
req.session.save(function() {
res.status(200).json({ id: req.body.UserID });
});
console.log("SEND USER ID", req.session);
};
sendUserID();
});
这会记录下来,我们可以根据需要进行会话
SEND USER ID Session {
cookie:
{ path: '/',
_expires: 2019-06-20T03:43:47.081Z,
originalMaxAge: 60000000,
httpOnly: true },
UserID: '',
userType: 'CF',
ID_Lingua: 'PT',
ID_Moeda: 'EUR',
userName: null,
token: null,
categorySelected: null,
ConsultantType: '1',
userIDGuest: 'jx34n1dyjx34n1dzjx34n1e0' }
但是我这样重新获取了
export function fetchCart() {
return dispatch => {
dispatch(loadingCart(true));
return new Promise((resolve, reject) => {
dispatch(fetchCartBegin());
return fetch("/get/minicart", {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/json"
}
})
.then(handleErrors)
.then(res => res.json())
.then(json => {
resolve({ cart: json.cart });
dispatch(fetchCartSuccess(json.cart));
dispatch(loadingCart(false));
// console.log("JSON", json);
return json.cart;
})
.catch(error => dispatch(fetchCartFailure(error)));
});
};
}
当我在服务器端打印会话时,我得到了
CARRINHO Session {
cookie:
{ path: '/',
_expires: 2019-06-20T03:43:47.325Z,
originalMaxAge: 60000000,
httpOnly: true },
UserID: '',
userType: 'CF',
ID_Lingua: 'PT',
ID_Moeda: 'EUR',
userName: null,
token: null,
categorySelected: null,
ConsultantType: '1' }
有人可以帮忙吗?无法弄清楚丢失会话的浏览器是什么问题...