hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Satish Mittal <satish.mit...@gmail.com>
Subject setting Cookie as Object vs as Request Header
Date Wed, 29 Jun 2005 10:01:04 GMT
Hi!

    I am implementing cookie based session maintenance. For testing, I
have 2 small client java apps built using HttpClient library, that
connect to my tomcat server. The 1st app connects to server, gets a
cookie and stores it somewhere as a string. The 2nd app takes that
cookie and *tries* to send that cookie. Now

1)  When i set a cookie in client request as:

postMethod.addRequestHeader("Cookie","SessionCookie1=TopSecret;domain=localhost:4000");

it doesn't work; the cookie doesn't reach server.

2)  Whereas if i populate a cookie object like this and set it in
HttpState object:

Cookie ck1 = new
Cookie("localhost:4000","SessionCookie1","TopSecret","",null,false);

This cookie gets set in request and reaches the server.

Why doesn't the 1st scenario work? The problem in scenario 2 is that
my client will get the entire cookie string as input from somewhere,
which means i will have to parse that string to get various attribute
values to populate Cookie object. In Scenario 1 i wouldn't need all
these and i can just send the string as it is.

Thanks in advance!
--Satish

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


Mime
View raw message