Android: log into website and preserve session/cookie using DefaultHttpClient

前端 未结 4 1675
死守一世寂寞
死守一世寂寞 2021-02-08 11:08

I\'ve been through different tutorials and this website, but couldn\'t find a proper solution. On the other hand, I\'ve seen apps logging into websites and requesting further in

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-08 12:03

    Assuming your httpclient object is the same in both cases, and assuming the RESTRICTED_URL is in the same domain as the LOGIN_URL, then I would think what you have should work.

    You might wish to use Wireshark or a proxy or something to examine the HTTP requests you are making, to see if the cookie is actually being attached to the request. It may be that the cookie is being attached, in which case there is something else wrong that is causing your second request to fail.

提交回复
热议问题