Sunday 6 December 2015

New Sessions isn't being set when new user goes on page?

Hi!I am working on a node project for the past few weeks and I need the ability for users to login. In PHP I have always used $_SESSION for this so this is why I have assumed that node.js have the same functionality. I have been following this tutorial: http://ift.tt/1SIkB5B haven't noticed the problem until now because I put the app on heroku and I noticed that when I was logged in on one computer and went on another computer and visited the website, I was still logged in into the original users account!Here is the code for the node.js file: http://ift.tt/1Qa2WWB think the problem has to do with the middleware from line 109 to 119:app.all("*", function (req, res, next) { sess = req.session; //Create session variable on ALL pages if (sess.user) { app.locals.signedYesOrNo = sess.user; } else { } next(); //Passes on to the next router }); This is the only thing I have changed from the tutorial as instead of writing sess = req.session on EVERY router I just put it into this middleware.Any help will be greatly appreciated!

Submitted December 07, 2015 at 07:23AM by mre12345

No comments:

Post a Comment