How to check if current user is logged in android

前端 未结 5 976
日久生厌
日久生厌 2020-12-14 23:24

How to check if current user is logged in android. I have an external database, I have successfully connected it to the database. I need to check if the user is logged in or

5条回答
  •  有刺的猬
    2020-12-14 23:59

    If you just want to test if the user is logged in to the device, it is sufficient to do this with SharedPreference as others indicated.

    However, if you want to ensure that the user is logged in to your external website, it is more complicated and requires more work.

    1- Your website should have remember me functionality by setting some cookie

    2- Once the user logged in successfully to your website from the app; you need to preserve the remember me cookie (e.g. serialize it to some file)

    3- When the user open the app, you have to load that cookie if exists and make a request to the server to ensure if the user still logged in or not (e.g. handle the HTTP response code)

提交回复
热议问题