如何实现在Android应用程序的cookie [英] How to implement cookie in android application

查看:136
本文介绍了如何实现在Android应用程序的cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Android的登录应用程序。

I want to make a login application in Android.

项目的要求是存储的用户名和密码,使用cookie的两天。

Requirement of the project is to store user name and password for two days using cookie.

是否有可能使用cookies?如果是,那么如何?你能给我的code?

Is it possible to use cookies? If yes, then how? Can you give me the code?

请注意:我不能使用Web视图

Note: I can't use web view.

推荐答案

作为一个评论者已经说了,你不应该来存储(即使是在加密的形式)的密码在cookie中。你可以存储为会话ID。当用户登录该应用程序,该应用程序会为他/她的会话ID,这将保持有效两天。在您对应用的每个请求,您可以添加会话ID作为HTTP标头。

As a commenter already said, you aren't supposed to store password (even in encrypted form) in a cookie. What you can store is a session id. When user logs in the application, the application generates a session id for him/her, which will stay valid for two days. In every request that you make to the application, you add the session id as an HTTP header.

您可以存储会话ID和日期时间它在preferences发行。当用户需要对应用程序的新请求,并在会议尚未到期,可以读取存储的值。

You can store the session id and the datetime it was issued in the preferences. When the user needs to make a new request to the application and the session hasn't expired, you can read the stored value.

这篇关于如何实现在Android应用程序的cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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