0

I have following code in app.js when I tried with Chrome, Firefox & Safari req.logout() working fine at back-end side but when I tried logout with IE browser than It's not working. I used Following code for setup session and logout API.

// set up our express application
app.use(cookieParser());

// required for passport
app.use(session(
    { 
        secret: 'SECRET',
        resave: true,
        saveUninitialized: true,
        maxAge: new Date(Date.now() + 1*60*60*1000),
        store: new MongoStore(
            {
                mongooseConnection : mongoose.connection
            }
        )        
    }
)); // session secret

app.use(passport.initialize());
app.use(passport.session()); // persistent login sessions

Logout GET API

req.logout();
req.session.destroy(function(err){
   req.user = null;
   req.session = null;
   res.cookies('connect.sid', "", { expires: new Date(0)})
});

Please suggest me better way to clear cookies on IE.

Gunjan Patel
  • 2,342
  • 4
  • 24
  • 45

1 Answers1

0

I found my own way, it's silly mistake.

In IE browser by default, It's caching APIs, My API first time caching after logout and re-login, Because of already caching It's not calling API to the server side, It's taken from the cache.

I found the solution. I used cache: false parameter in $.ajax call.

Gunjan Patel
  • 2,342
  • 4
  • 24
  • 45