简体   繁体   English

phonegap和php之间的身份验证

[英]authentication between phonegap and php

i need a system of authentication between phonegap and php. 我需要在phonegap和php之间进行身份验证的系统。 I make a request by ajax sending the user and pass. 我通过ajax发送用户并通过请求。 Php make the query mysql with these data if is correct it is return the PHPSESSID and save with javascript in LocalStorage. PHP使用这些数据对MySQL进行查询,如果正确,则返回PHPSESSID并将其保存在LocalStorage中。 when this user make actions as comments, upload photos.. check if exist PHPSESSID in LocalStore and check this PHPSESSID in php. 当此用户作为评论操作时,上传照片..检查LocalStore中是否存在PHPSESSID并在php中检查此PHPSESSID。

Is correct make this? 是正确的吗?

It's better if you use RESTful principle which means the server is stateless. 最好使用RESTful原则,这意味着服务器是无状态的。 Try to dig up on how to make web services using rest. 尝试深入了解如何使用Rest来制作Web服务。 There should be tons of examples where you can try on. 应该有大量的示例可以尝试。

OAuth springs to mind. OAuth浮现在脑海。 Store the token in localStorage rather than storing the session ID. 将令牌存储在localStorage中,而不是存储会话ID。 That way, you can quickly and easily recall it. 这样,您可以快速轻松地调用它。

You can also tweak your OAuth provider to auto-refresh tokens that are used, so tokens never really expire. 您还可以调整OAuth提供程序以自动刷新使用的令牌,因此令牌永远不会真正过期。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM