How to manage session for a user logged in from mobile app in PHP?

前端 未结 7 2013
暖寄归人
暖寄归人 2020-12-23 02:13

I\'m a PHP programmer by profession. So, I don\'t have any idea about iOS and Android coding.

The scenario is there is one website developed using a

7条回答
  •  臣服心动
    2020-12-23 02:44

    I dont have any experience working with PHPFox but this is how a mobile frontend should ideally handle the issues:

    Case 1: Mobile app actively talking to server:

    • Session timeout stamp keeps bumping up and session stays alive.

    Case 2: Mobile app active without any server communication (e.g. incoming phone call, moving between apps etc.):

    • Server session may or may not timeout.
    • If it times out, next query to server will fail auth and return an error.
    • App consumes this error and gracefully redirects to login screen with a message toast urging the user to login. (This happens in my banking app)

    Case 3: User kills the app on device and relaunches it:

    • The app should store the token either in sqllite or shared preferences. (Always logged in apps take this approach)
    • Upon relaunch, app can query the server with the presistent token.
    • If session is alive, communication goes through and user can continue. If not, user goes to login screen as in Case 2.

提交回复
热议问题