Why is the Client Side Session Timeout so Short?

I have noticed when I leave an app open for 20-30 minutes without a server request and then try to make a server request after I have finished all my client side work, I get a Session Expired message.

This means I have to copy all my work over elsewhere and start over. It’s much faster than the 1st time of course, but very annoying that I need to do this about 2/3 of the time.

Is there a reason that it expires in under an hour?

1 Like

I’ll leave Anvil’s authors to answer your direct question.

As for this irritation…

… there are workarounds elsewhere on the Forum. So, strictly speaking, you don’t have to do that, if you take advantage of one of them.

What are those solutions you are referring to? It’s not really helpful being so oblique :sweat_smile:

I also don’t want to involve data tables as this is just supposed to be a lightweight app that give me a structured file.

Well, it might be, if forum search wasn’t right at the top of every forum page:
image

Self-serve can be much faster than waiting for a forum volunteer to answer. I use it frequently. Highly recommended.

One favorite approach, that does not require database access, is with a Timer component. Enable it, and set its handler function to make an anvil.server.call every 15 minutes or so. Each call resets the session clock. My colleague has had sessions running for weeks

The session timeout is 30 minutes. For some, that’s ideal; for others, it may feel too short or too long.

One advantage of this timeout is that it prevents someone from using a browser that’s been left open and idle for hours or days, especially on a shared or unattended machine.

Here, a Timer is your friend.

If 30 minutes is too long, you can reset your own inactivity timer on each user interaction and trigger a logout after 5 minutes of inactivity, just like many banking sites do.

If it’s too short, you can use a Timer set to fire every 29 minutes and call a server function. The server function doesn’t need to perform any logic; calling it is enough to keep the session alive by resetting the 30-minute inactivity timer.

1 Like

If losing your not-saved work is the primary concern, you can also look into using Local Storage to save the work that hasn’t been submitted yet. I use that on an app and the user can accidentally close the tab and reopen the app and be exactly where they were, no work lost.