hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "micky" <micky_...@cyberpowersystems.com.tw>
Subject cookie or session-id is different from the same HttpClient connection?!
Date Thu, 28 Feb 2008 09:19:09 GMT

I use the HttpClient to login some page, and it will have a cookie according to my login.

But when I try to access another page (needed for logon) by the same HttpClient, the response
is access denied. 

Then I print out the cookies of the two connection, I found them are different.

But the document said I don't need to care the cookie issue when I use HttpClient to login
and continue browsing other pages.

Here is some sample pseudo code to demo.

DefaultHttpClient httpclient = new DefaultHttpClient();

HttpPost httpPost = new HttpPost("");

// response 200, and login ok!
HttpResponse response = httpclient.execute(httpPost);

HttpEntity entity = response.getEntity(); // cookie with a session id "1" for example

// continue to another page
httpPost = new HttpPost("");

// response 200, and access denied
HttpResponse response2 = httpclient.execute(httpPost);

HttpEntity entity2 = response2.getEntity(); // cookie with a session id "2" for example

// the session is different

I think the session id in the cookie should be the same, so that I can browse all pages after
the first logon action.

But the truth is not?! How it can be that??

Thanks for any reply or suggestion.


To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org

View raw message