简体   繁体   中英

Clear browser session data with Express in nodejs?

As the user loges in, I add some user info into browser sessions on the client side(angular):

$window.sessionStorage.setItem('loggedInUser', JSON.stringify(val));

On the backend I have such user (Passportjs)authentication for logout:

app.get('/logout', isLoggedIn, function(req, res) {
    req.logout();
    res.redirect('/');
});

It logs the user out and redirects but my angular app doesn't have the '/logout' api. So I can't call

sessionStorage.clear();

as the '/logout' is triggered.

Is it possible to clear browser session storage on the backend in nodejs?

If you're trying to get the end user's browser to use a more up to date plugin etc... there are ways of doing this by changing the file name, sometimes guid's are appended to the end of the file that someone is trying to not get cached or recached upon download.

There is a plugin for cachebusting in express.js but I'm not sure it's necessary to install a plugin, then again you may not want to reinvent the wheel. https://github.com/niftylettuce/express-cachebuster

There are several ways of dealing with cached files to force the client's browser to use an updated copy, this is just one example of how that can be done.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM