[英]Android HttpClient cookies
I am trying to make an app for a website. 我正在尝试为网站制作应用程序。 The Login works fine but when I try to send GET requests now the session id cookie isn't send. 登录工作正常,但是当我尝试发送GET请求时,未发送会话ID Cookie。 The HttpContext with a CookieStorage is set up like this: 带有CookieStorage的HttpContext设置如下:
public static final HttpContext LOCALCONTEXT = new BasicHttpContext();
LOCALCONTEXT.setAttribute(ClientContext.COOKIE_STORE, cookieStore);
than that's the login: 而不是登录名:
HttpResponse response = httpclient.execute(httppost, LOCALCONTEXT);
and that's the GET request: 这就是GET请求:
HttpResponse response = httpclient.execute(httpGet, LoginActivity.LOCALCONTEXT);.
With 用
Log.d(LoginActivity.NAME, "Cookie1:= " + LoginActivity.LOCALCONTEXT.getAttribute(ClientContext.COOKIE_STORE).toString());
i logged the saved cookies before and after the GET request. 我在GET请求之前和之后记录了保存的cookie。 They are the right ones. 他们是正确的。 But than i sniffed the traffic of the emulator and the cookie isn't sent. 但是比起我,我嗅到了模拟器的流量,并且没有发送cookie。 Why? 为什么?
Solved. 解决了。 Problem was that I logged in to the page "http://WWW.arenakampf.de" and sent the GET to "http://arenakampf.de" :/ 问题是我登录到页面“ http://WWW.arenakampf.de”并将GET发送到“ http://arenakampf.de”:/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.