Our system has a one hour session length. Occasionally this will expire just before a user presses a 'Save' button on a form. When the session times out, they get kicked back to the log in page and their data is lost. This is obviously bad.
I'm trying to think of a better way to handle this situation. Here's what I've come up with:
- Start a 55 minute timer in JavaScript on every page load. When it runs out, pop up a message saying "Your session is about to expire, click here if you're alive".
- Clicking the link would send an AJAX request back to the server to reset the session
- What if they don't click the link in the next 5 minutes because they've legitimately had to step away from their computer for a minute, but still have a massive form in the works?
- Poll the server every 30 seconds or so to find out when exactly their session has expired, and then display a login screen in a popup when it has
- Let the session expire. Copy the POST data somewhere safe (where??). When they try saving the form, they will get kicked to the login form as usual. After a successful login, re-POST the data to the proper location.
How do others deal with this situation? What's the best/easiest approach?