Keep the user always connected to app

Hi,

I have built a simple app where users login and start recording their productive hours, storing the time in table. This means that the app will stay open for at least 8 hours. During this period the app doesn’t store anything. When the user wants to logout at the end of the shift if the connection with the server is lost can’t find the user and get the common error, so it’s impossible to logout.
I settled a timer that displays a clock to keep ticking to keep active the app, but without result.
I also read about offline app but can’t find a way if the connection is lost and than the internet connection is recovered, or session has expired how to keep the user logged in again without log in again manually.
Maybe it’s difficult for me to understand how offline requests really works.

Thanks

You can keep the session alive using a timer to call a server function once every 29 minutes.

The server function doesn’t need to do anything, it can contain just a pass.

You can use call_s instead of call to avoid the spinner.

1 Like

Thank you for your support, but if the internet connection is lost and established again the app will still be online a the end?

Thanks

You can keep the user signed in with the “Remember me” checkbox:

If the connection is lost for longer than 30 minutes, then the session will timeout and the user will need to press F5 to refresh the page. After the refresh, the user will be still logged in.

Connection errors while the tick event does the server call will show up as error message on the bottom right corner. If you don’t like that, you can wrap them in a try/except (and make them a little more often, let’s say once every 5 minutes).

1 Like