Making back button not logout the user

I’m using enableBrowserArrows to make the standard android back button work, but I have this quirk:

My app has an initial login screen, which makes an ajax call to authenticate the user and if ok, goes to the main form of the app.

Then the user navigates the app, and if he presses the back button while on the main form, he gets back to the login form, but:

  1. He’s not really logged out, so the app state is not ok
  2. I really DON’T want this to happen: my idea is that the user should remain logged in until he specifically logs out (there’s a proper logout button in the app).

What can I do to make back button work as a “back to the OS” button when in the app home screen?

You could set your “main form” form as the 1st form. If user needs to login then form.show the login form rather than changeform(loginform) Browser still thinks it is in mainform as you are just displaying the loginform not actually changing to it. You’ll see the address bar still displays the address of the mainform. This is where I’m not 100% sure but I’d expect the back button to then revert to your homescreen.

That’s a very nice idea, thanks!