I’m trying to loggin to remote server with login and password and it’s done. But when I’m removing request with password and login and restart my app, I’m unable to login to the same server. I was told that I can do it because cookies have to be stored automatically. What I’m doing wrong?
For instance, we have DefauktHttpClient. How to store cookies there? What is the cycle of storing them? If I understand correctly, cookies help user to stay loginned on server. (we are tolking about logining from mobile device). My goal is not to send login/password of user for doing every operation. How to do it correctly?
Cookies are values in HTTP header in form key:value. And information about logged user is usually stored here in form of some generated login key. For example cookie will be userID:1234
You can also write your own simple cookie manager. After you sent login request use
HttpURLConnectionmethod (or similiar) togetHeaderFields().get("set-cookie"). Save all cookies or those which you need and before next request usesetRequestProperty("Cookie", savedCookies). For saving you can you use SharedPreferences.