简体   繁体   中英

Maintain sessions on server side in node js

I am creating an application in Reactjs , nodejs and mongodb . In it, when user login into website, I am saving current time he logged into application and saving into database. And then saving userId and jwt into localStorage . And i implemented a functionality that, user can't logout until he didn't added his schedule for today and didn't send the status report and it is working well.

But when User clear localStorage manually and reload the page, he successfully logout from the application and logout time not saving into db, which i want to prevent .

So my concern is that, is there anything in nodejs , so that i can save userData into sessions on server side except saving it in localStorage?

@Rajat —- transmit jwt or userid via websocket to nodejs and keep a list of active logins. If user does a local flush and logs in again — caution them that they have to repeat everything. Maybe easier to transmit data as they enter via websocket or use package like express-session

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