We have an Angular web application with session management logic to renew session tokens. However, we’re currently encountering issues where session renewal throws a 401 error in some cases. Additionally, the background renewal using Iframe document load during renewal also gets stuck in certain situations, such as when the system goes idle for longer than the session renewal time(suppose renew time in about to 30mins).
I’ve been researching how to handle session renewal effectively, especially when browser tabs become inactive/active or when the network goes offline/online. However, I haven’t found clear guidance on how to ensure it works seamlessly in all scenarios.
Could you please share any insights or experiences you’ve had with this issue? What are the pros and cons of different approaches? Which approach ensures reliable session management across all scenarios and how or sample example?
for example
document.addEventListener("visibilitychange", () => {
console.log("visibility change event to handle some session scenario")
})
window.addEventListener("offline", (event) => {
console.log("The network connection has been lost to handle session");
});
window.addEventListener("online", (event) => {
console.log("You are now connected to the network to handle session");
});
Thanks in advance.