How to retain my login or session

if i login to my app, once it lost its focus, it goes back to the 1st page or login.
what should i add to my lua file in order not to lose what the user is currently doing?

thanks!

That’s probably a backend thing where the session expires but can you provide more details about the situation?

scenario:

  1. user login his credentials
  2. authenticated. redirected to users page. open some pages.
  3. suddenly he pressed home.
  4. page goes back to login.

is there a way i could retain the page before he pressed home or any button

If what you described above is NOT a cold start, you can use composer.setVariable() to keep track of the current scene - https://docs.coronalabs.com/api/library/composer/setVariable.html

Best way to set variable is when a scene is shown. You don’t need to wait until the application is sent to background but if you want, you can use applicationSuspend to set variable at that moment. Beware of the gotchas though - https://docs.coronalabs.com/api/event/system/type.html

If that is indeed a cold start where the OS kills your app for some reason, this means the best practice is that you check for login credentials again. You can do it like how popular applications like Instagram does where they save your login credentials and call for an automatic login on that page. This is all about reading and writing files with a little bit of crypto.*(https://docs.coronalabs.com/api/library/crypto/index.html) on the side.

Thanks!

Will try it.