0

What would be the best way to handle this? Say you have a session timeout of 20 minutes. The time before your session is timed out, is supposedly reset on every page refresh. I have a webpage that has, say 200 input fields and text areas, which sometimes takes longer than 20 minutes to fill out for the user. The user can hit a save button which saves the data, refreshes the page (hence resetting the time to timeout) and shows the page with the already entered data. I'm thinking how I can help the user not lose their data. The site uses PHP

  1. There could be a timer that starts counting down from 15 minutes after first input keystroke is registered using jquery or javascript, and when 15 minutes is passed the user is notified that they should remember to save the content.
  2. There is an AJAX call happening on keyinput and every 10 minutes to another page on the same website with session_start to keep the session alive.
  3. Data is saved automatically every X minutes via AJAX in the background, however this method is not preferred by the staff here.

Have you dealt with this before, and how would you say is the best way to do it?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Daniel Jørgensen
  • 1,183
  • 2
  • 19
  • 42
  • 1
    `best way to do it` is subjective, which is off topic for SO. Can't increase session life? https://stackoverflow.com/questions/12597176/how-to-keep-session-alive-without-reloading-page might be a relevant dup. – user3783243 Jul 05 '22 at 14:12
  • 1
    _"I'm thinking how I can help the user not lose their data."_ If you know your form takes longer than 20 minutes to fill out, then maybe don't set a timeout of 20 minutes? Beyond that, 200 fields is a huge amount for a single page. A better user experience would be to split those into smaller groups and then submit per group. – Alex Howansky Jul 05 '22 at 14:33
  • "*Say you have a session timeout of 20 minutes*" - I would not have a "session timeout". Why is there even a "session timeout"? What feature of your website needs this session timeout? Can you go stateless? (=> no timeout) – freedomn-m Jul 05 '22 at 15:30
  • 4 hours seems a bare minimum to me, 20 minutes is way too short – Lk77 Jul 06 '22 at 20:47
  • 20 minutes before timeout, and 200 input fields was only mentioned as an example. Point is its enough data and low enough time that people do timeout before completing the form. Changing the timeout is not an option currently. – Daniel Jørgensen Jul 07 '22 at 06:36

0 Answers0