You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Oleg Kalnichevski <ol...@apache.org> on 2008/02/29 10:13:45 UTC
Re: cookie or session-id is different from the same HttpClient
connection?!
On Thu, 2008-02-28 at 17:19 +0800, micky wrote:
> Dear,
>
>
> 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("http://127.0.0.1/login.html");
>
> // 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("http://127.0.0.1/info.html");
>
> // 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.
>
> Sincerely,
> Micky
>
Micky,
Please execute your application with the 'org.apache.http' logger set to
DEBUG.
-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog -Dorg.apache.commons.logging.simplelog.log.org.apache.http=DEBUG
Feel free to post the log to this list if you need help figuring out the
cause of the problem.
Oleg
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org