dongle7553 2017-03-04 14:22
浏览 162
已采纳

如何从服务器识别用户以处理请求

I would like to know how to identify user from server when any request from app is done. Like if I have logged into the app and want to update my profile and send the request to server. How will the server identify the request is from particular user ? I am using PHP as server language and storing user session using Shared Preferences.

Any help would be helpful.

  • 写回答

2条回答 默认 最新

  • dongzhi6927 2017-03-04 14:28
    关注

    The easiest way to accomplish this outcome is to attach a unique identifier to the user(randomly generated) .Store this information along with the time,name and identifier of the user in the database. Also persist in the app, shared preference is alright. But consider using databases.A great one is realm for android. Then when any request is sent to the server send the name of user along with their identifier perform a query search with this information. Thus returning any info stored for this user.

    Make any sense? Well there are other sophisticated approaches that can be tailored to your needs. the concept of shared preferences is to store small transient information. using a database permits much safer control over your data and managed operations asynchronously,which will pay a big role later when traffic is encountered. Consider web tokens as well for communication. JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. This information can be verified and trusted because it is digitally signed. JWTs can be signed using a secret (with the HMAC algorithm) or a public/private key pair using RSA.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog