应用统一做接口,android端,ios端或者微信公众号端全部通过API接口和WEB服务器做数据交互,如登录,用户注册,登陆后的一些操作等。(原生应用,不是用WebView封装的H5 url)
我是菜鸟,有个问题有点迷糊。求教各位网友,谢谢!
发一个请求给服务器,传递用户名和密码,验证成功后返回用户的UID,客户端(android为例)直接使用 SharedPrefence 保存这个UID就可以了。
为什么我在网上看到很多人说再次HTPP请求时把cookie附加到header里,这样就不用重复登录了?(cookie里保存什么东西?)
既然客户端通过自定义API接口和服务器交互,GET或者POST时传递令牌验证参数不就可以了啊,还要cookie作甚啊??
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
The Api key tells the server that the caller server is legal, and the cookie tells the client that the user is legal
Native applications do not require cookies and directly determine the login status based on the user number
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
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.
The key now is how to bring cookies into httpheader?