Android HttpClient persistent cookies

You can do what @Emmanuel suggested or you can pass the BasicHttpContext between the HttpClients you are creating.

Example Use of context and cookies, complete code here

    HttpClient httpclient = new DefaultHttpClient();

    // Create a local instance of cookie store
    CookieStore cookieStore = new BasicCookieStore();

    // Create local HTTP context
    HttpContext localContext = new BasicHttpContext();
    // Bind custom cookie store to the local context
    localContext.setAttribute(ClientContext.COOKIE_STORE, cookieStore);

    HttpGet httpget = new HttpGet("http://www.google.com/", localContext);

Leave a Comment

tech