我试图从Angular使用Express-Session,但设置该会话无效,如果我尝试检索会话变量,我会得到“未定义”,这是代码:
import cors from 'cors';
app.use(cors({origin:["http://localhost:4200"], credentials: true}))
app.use(require('express-session')(
{
secret:'somme',
resave:false,
saveUninitialized:true,
httpOnly:false
}))
app.post('/api/signin', api.signIn)
signIn: (req, res)=>{
req.session.e = '123'
} // defined in api module
app.get('api/checksession', function(req, res){
req.session.e //undefined
})
为什么变得不确定?