Automatic refresh on session timeout

Hello Anvil Team,

When the session expires in my anvil app, I get a notification telling me my session has expired and that I should refresh to continue. Instead of asking the user to manually refresh, I think it would be nice to automatically refresh the page on session timeout.

Update: If at all, this request cannot be changed, whenever a connection to server fails or a session ends and the notification pops up, please can you make the color of the notification green or some other user friendly color as oppose to red. Red makes the user thinks it’s an error, when technically it isn’t.

Thanks and hoping to hear back from you.

Sometimes a session timeout is good to avoid sensitive data to stay on an unattended computer for too long.

If you want to keep the session alive you can put a timer on a form that calls a server function once every 25 minutes. The server function will do nothing, calling it is enough to keep the session alive. Use call_s to avoid the spinner.

1 Like

Currently, I do that. However, Anvil doesn’t allow an application’s session to stay open forever. So even though I call a server function to continue the session, at some point, which I don’t know when, Anvil ends the session and a notification comes up telling you to refresh to continue.

You can catch the session expiry errors and reload the session. See the docs on error reporting to see how to intercept that error, and the docs on session expiry to see how to recover!

Thanks @meredydd. Where exactly am I to write this code? Client side or server side?