android登录问题
PHP中文网
PHP中文网 2017-04-17 17:57:37
0
2
383

android登陆成功后在SharedPreferences中存储数据 android登录大多数都是登陆一次 下次不用输入密码 这是怎么实现的?因为我想如果服务器那里有session,那android登录很快就会失效,

PHP中文网
PHP中文网

认证0级讲师

reply all (2)
巴扎黑

First: You can try JWT, which is a kind of Token and does not require a session. I recently made an APP and found it very good.
Second: session process (1) APP sends user name and password to the server; (2) The server queries the database for the correct user name, generates a session, stores it in memory, and returns the cookie to the APP. (3) The APP receives each request with a cookie, and the server determines whether the cookie is correct and outdated through the session.
Third: The simplest way to implement it.

第一次登录后,将用户名,密码,cookie一起存储在SharedPreferences;每一次请求带有cookie,如果过期,则服务器通过自定义的状态码告知APP,则APP从SharedPreferences取出用户名,密码,发起登录请求,成功后,刷新SharedPreferences中的cookie。
    PHPzhong

    First, you can set the server session time to be longer. If the session fails, the login page will be redirected to allow the user to log in again.
    Second, you can silently call the login interface in the background during the Splash page to help users log in automatically.

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!