Android应用程序策略保持登录会话跟踪 [英] Android App Strategy for keeping track of a login session

查看:372
本文介绍了Android应用程序策略保持登录会话跟踪的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些登录,并返回一个JSON阵列,会话ID,如果登录成功PHP脚本。

I have some PHP script that logs in and returns a JSON array with a session ID if the login was successful.

在我的应用程序,我想登录的头版,并继续了通过应用程序被登录。我创建了一个拥有会话ID(连同其他一些领域)单个类从JSON收到来自PHP页。这种单对象的字段SESSION_ID被视用户做什么检查。

In my app, I want to login at the front page and continue out through the app being logged in. I created a singleton class that holds a session ID (along with a few other fields) received from the JSON from the PHP page. This singleton object's field "session_id" gets checked depending on what the user does.

如果用户想注销,然后SESSION_ID刚刚被设置为null,从而退出。

If the user wants to log out, then the session_id just gets set to null thus logging out.

我也用的HttpURLConnection库POST登录时的用户名/密码。

I also use the HttpURLConnection library to POST the username/password when logging in.

这是一个足够体面的方式来处理这种情况呢?

Is this a decent enough approach for handling this situation?

推荐答案

这里有一些事情你应该想想:

Here are some things you should think about:

  • 一旦你验证了用户和本地存储的SESSION_ID,发送SESSION_ID在你的每个HTTP请求的报头。这样一来,你不发送与每个请求的凭据,但会话ID。如果事情发生在服务器端的会话,该交易将不会被允许。
  • 当注销,不只是删除你的应用程序(客户端)侧SESSION_ID。发送注销的服务器,以及这样的会议可以杀死服务器端。
  • 如果会话被杀害在服务器端,你需要做1〜2的东西)提示用户重新登录的用户。 B)使用存储的凭据重新登录,创建一个新的会话ID,并重新将其存储在你的单身。

这将保证更多的安全性和功能不仅仅是清除会话ID在你的应用程序的一面。

This will guarantee a bit more security and functionality than just clearing the session id on your app side.

这篇关于Android应用程序策略保持登录会话跟踪的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆