0

私はこのコードを使用していますが、Cookieを設定していません...

URL url = new URL("http://10.0.2.2/test2.php");
                HttpClient httpClient = new DefaultHttpClient();
                CookieStore cookieStore = new BasicCookieStore();
                Cookie cookie = new BasicClientCookie("xxt", "5a5b98563c4aabd675b81e4ba0fdf6cf");
                cookieStore.addCookie(cookie);

                Cookie cookie2 = new BasicClientCookie("XXT", "5a5b98563c4aabd675b81e4ba0fdf6cf");
                cookieStore.addCookie(cookie2);

                HttpContext localContext = new BasicHttpContext();
                localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

                HttpPost post = new HttpPost("http://10.0.2.2/test2.php");
                HttpResponse response = httpClient.execute(post, localContext);
                toReturn = EntityUtils.toString(response.getEntity());
                //InputStream is = conn.getInputStream();
                //toReturn = inputStreamToString(is).toString();
                Log.d("downloaded", toReturn);

私は何を間違っていますか?

4

1 に答える 1