Home  >  Q&A  >  body text

android - APP开发 与后端交互Cookie的问题

应用统一做接口,android端,ios端或者微信公众号端全部通过API接口和WEB服务器做数据交互,如登录,用户注册,登陆后的一些操作等。(原生应用,不是用WebView封装的H5 url)

我是菜鸟,有个问题有点迷糊。求教各位网友,谢谢!

发一个请求给服务器,传递用户名和密码,验证成功后返回用户的UID,客户端(android为例)直接使用 SharedPrefence 保存这个UID就可以了。

为什么我在网上看到很多人说再次HTPP请求时把cookie附加到header里,这样就不用重复登录了?(cookie里保存什么东西?)

既然客户端通过自定义API接口和服务器交互,GET或者POST时传递令牌验证参数不就可以了啊,还要cookie作甚啊??

迷茫迷茫2720 days ago444

reply all(6)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 13:12:49

    How can we get cookies without a browser? Cookie and session explanation, pure native app (no WebView) I have never heard of the concept of cookies, maybe I am ignorant

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 13:12:49

    The Api key tells the server that the caller server is legal, and the cookie tells the client that the user is legal

    reply
    0
  • ringa_lee

    ringa_lee2017-04-17 13:12:49

    Native applications do not require cookies and directly determine the login status based on the user number

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 13:12:49

    When making web applications, cookies are generally used to pass session id. For example, PHPSESSID. In fact, it is equivalent to the function of a token.
    The app passes cookies, probably to be consistent with the web page. In this way, the server can handle both Web and App requests at the same time

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 13:12:49

    You can think of this cookie as a key. Based on this key, you can get some information stored in the user's login state, such as uid, etc.

    reply
    0
  • 巴扎黑

    巴扎黑2017-04-17 13:12:49

    The key now is how to bring cookies into httpheader?

    reply
    0
  • Cancelreply