我浏览了几篇文章,没有什么比一段清晰的代码更能让我只需查看并收集所有想法。每个人都会发布他们的应用程序的一小部分,我不确定什么对会话/登录至关重要,什么仅对他们的应用程序至关重要。
过程:
- 使用用户/密码初始登录。密码将在服务器端进行md5加密和匹配。
- 如果用户/密码正确,请求中的会话 ID 将存储在服务器端,并且来自同一会话 ID 的任何未来请求都将提供适当的数据。
我需要什么:
- 一个简单的JSON请求,可以完成GET/POST请求。发布用户/通行证。获取以供将来查询。
- 一段代码,将保留会话 cookie 并将其应用于任何进一步的 GET/POST 请求。
我的测试:
我将尝试请求一些信息(出于测试目的,字符串;“pass”)。如果没有确认登录,我的服务器将在登录后返回“失败”,我希望它返回“通过”。然后我将进入数据库更改存储的会话 ID。刷新我的应用程序,让它再次从“通过”变为“失败”。
注意:我遇到的一个大问题是,当人们发布一段代码时却没有说明每个部分应该放在哪里。请明确代码块应该放在哪里。 (即在初始请求之后。作为一个单独的函数等)
我遇到的一个令人惊叹答案的示例。除了它没有任何代码,只是结构:/
登录会话 - 活动
I've looked around several articles and nothing is like a clear cut piece of code that I can just look at and gather all the ideas. Everyone posts little segments of their app and I'm not sure what is critical to the session/login and what is essential only to their app.
The process:
- Initial login with user/pass. Password will be md5 encrypted and matched on the server end.
- If the user/pass is correct the session id from the request will be stored server-side and any future requests from the same session id will be provided the appropriate data.
What I need:
- A simple JSON request that can complete GET/POST requests. Post for the user/pass. Get for future queries.
- A section of code that will retain the session cookie and apply it to any further GET/POST requests.
My test:
I'll try and make a request for a some information (for test purposes a string; "pass"). Without the login being confirmed my server will return "fail" after the login I'd like it to return "pass". Then I'll go into my database alter the session id that was stored. Refresh my app, and have it change from "pass" to "fail" again.
NOTE: A big problem I have is when people post section of code and don't say where each section should go. Please be clear where blocks of code should go. (ie. after the initial request. As a separate function, etc.)
Example of an AMAZING answer that I ran across. Except it didn't have any code, just structure :/
Login Session - Activities
发布评论
评论(1)
我想我找到了我正在寻找的东西。我决定实现这个示例:
http://old.metatroid.com/articles/Android%20Development%28part%201%29%20-%20Syncing%20Cookies%20Between%20Http%20Clients%20and%20WebViews
不确定如果它能满足我需要的一切,但到目前为止看起来还不错。到目前为止我找到的最好的例子。
I think I found what I was looking for. I've decided to implement this example:
http://old.metatroid.com/articles/Android%20Development%28part%201%29%20-%20Syncing%20Cookies%20Between%20Http%20Clients%20and%20WebViews
Not sure if it's going to do all I need, but so far it looks good. Best example I've found so far.