mozilla / node-client-sessions

secure sessions stored in cookies
Mozilla Public License 2.0
759 stars 104 forks source link

Redirect loses session information #104

Open sudeka opened 9 years ago

sudeka commented 9 years ago

Hi,

My code is pasted below. In the callback method, I set the user, but when I redirect to '/' the user is no longer available. I'm using passport and client-sessions. Any help would be greatly appreciated.

Thank you.

app.get('/', function (req, res) { if (req.session_state.user == null) { passport.authenticate('azureoauth', { failureRedirect: './'}) } else { res.render('index', {user: req.session_state.user}); } });

//This gets called by an external internet application
app.get('/auth/azureOAuth/callback', passport.authenticate('azureoauth', {}), function (req, res) { req.session_state.user = req.user; res.redirect("/"); });

And in my app.js, I have the following code: const clientSession = require("client-sessions"); app.use(clientSession({secret: 'blablabla', duration: 1000 * 60 * 60 * 24 * 365 * 10})); app.use(passport.initialize()); // for uauthentication/authorization app.use(passport.session());

Sunkari16 commented 9 years ago

Even I'm facing the same issue .. Any workaround ?

arcman7 commented 8 years ago

Also having the same problem, any updates?

occasl commented 7 years ago

Same problem here. Did you find a sufficient work around?

Sanscripter commented 6 years ago

No workaround but I didn't have a problem with this until we tested on firefox. For some reason it won't save properly. I tried to swap the redirect for a call in the frontend but to no avail.

Does anyone know a better package for this situation? Even express-session had been malfunctioning for this.