How to remain logged in until user decides to logout?

前端 未结 2 1452
野的像风
野的像风 2021-01-29 02:57

I am designing an app that it uses the web service like posting links and pictures. The first view controller checks the default username and password of the user and if it is c

2条回答
  •  日久生厌
    2021-01-29 03:13

    RestKit is designed to consume APIs. Usually APIs are stateless, meaning that there is no such thing as state between requests. On traditional websites state is achieved by transmitting cookies back and forth between client and server. Apparently RestKit does not handle cookies (which is good in my opinion). From the top of my head I can think of two solutions:

    • Apparently RestKit does not handle cookies automatically. Thus, you could get the cookie after the login and attach it to every subsequent request.
    • Better: use OAuth2, which is basically a token that the user receives when logging in. This token is then appended as a parameter to each request.

    Both methods are basically the same. You have to send a token that identifies the user as logged in.

提交回复
热议问题