node sessions not clearing in production

267
June 13, 2017, at 03:52 AM

I am using client-sessions with node and express, and I am having trouble logging out users.

my logout function does a

req.session.user=null 

that is:

userRouter.get('/logout', function(req, res, next) {
  req.session.user = null
res.sendStatus(200)
});

(I also tried delete req.user, req.user.destroy(), and other variants).

in dev env, on localhost, it works great. in production environment, logout is called, but the next time the user refreshes the page on the browser, the user is still logged in.

same code in dev and production.

Anybody has any idea? thanks....

Answer 1

According to this blog post on client-sessions, you can use this:

userRouter.get('/logout', function(req, res, next) {
  req.session.reset(); 
  res.sendStatus(200);
});
Rent Charter Buses Company
READ ALSO
Passport Local Remember Me Strategy

Passport Local Remember Me Strategy

I am trying to create a passport remember me strategy but I am not sure how to call itMy overall strategy is to store two tokens in my database and as cookies on the client's computer and compare then to verify that they are real users

350
How to match fs file dates with date ranges?

How to match fs file dates with date ranges?

I have a date range from client , so i am trying to see if any file that comes in this range only push that file to filesData , I have implemented below code but its not happening any idea where i am making mistake ?

331
Node.js server/client to connect to send and receive message

Node.js server/client to connect to send and receive message

i have a sensor that connects to a routerI need to create something in node

347