-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Session saved in the DB but req.session result is {"cookie":{"originalMaxAge":172800000,"expires":172800000,"secure":false,"httpOnly":true,"path":"/"}} #75
Comments
I don't understand the issue, can you please clarify what the expected behavior is and what the behavior you're seeing is? |
Session stored in the DB working fine. This part not working. req.session Reult is My session data not visible here. |
Same issue here.
And on app load, in my
My setup in
The |
Same for me. The session gets stored in the database, but not in req.session. Is there a special way to update the session for req.session? |
Ended up using pure cookies (storeless). next-iron-session. Just iron-session would work fine as well. |
I was having this same issue and spent so long trying to figure this out! But here's what fixed it: add this before session configuration: Add proxy option to session: |
hey, it still not working, I use the Redis store for sessions like that:
but result still:
I lost a few days... I'm already tired |
@DavidForDev I feel you. I tried for 3 days before getting it to work. There were a few other things that I did along the way that probably made a difference.
If you want you can check out my auth code here and my session code here |
thank you for your answer. I use different tools, so for more detail, you can see my post on Stackoverflow: https://stackoverflow.com/questions/77634864/trouble-accessing-session-data-in-express-redis-after-setting-from-apollo-client thanks |
var store = new MongoStore(
{
uri: process.env.ATLAS_URI,
collection: 'sessions'
},
function(error) {
// Should have gotten an error
});
store.on('error', function(error) {
assert.ifError(error);
assert.ok(false);
});
app.use(session({
secret: 'abcdefghijklm',
saveUninitialized: true,
resave: true,
cookie: {
secure: false,
expires: 1000 * 60 * 60 * 24 * 2
},
store: store
}));
app.post('/cart', function(req, res){
var cart = req.body;
req.session.cart = cart;
req.session.cart = cart;
req.session.save(function(err){
if(err){
throw err;
}
res.json(req.session.cart);
});
})
app.get('/', function(req, res) {
res.send(req.session);
});
The text was updated successfully, but these errors were encountered: