How to log out automatically without being active for a long time?

how to log out automatically without being active for too long?

and there are updates in the background. The web application logs out and the user logs in

Mar.19,2021

scheduled task scheme:

if loginExpire <= currentTime - lastActiveTime is true{//
    //do logout operations
}

caching scheme:

redis set(token, user, lastActivetime + loginExpire, timeUnit);//get&set

the front end checks whether the login status expires at regular intervals and automatically exits

Menu