dcsimg
How to accept cookies when using POST with URLConnection?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Duke_Nguyen
Posted On:   Tuesday, February 26, 2002 02:33 AM

Hi all,

I am using URLConnection to simulate a browser HTTP POST. However, the website (ebay) claims I cannot accept cookies? I have tried setting the "User-Agent", "Referer" fields etc...What am I doing wrong? How do I accept cookies? A code sample would be much appreciated...thanks!

Thanks!
Duke
dn415@ucla.edu

Re: How to accept cookies when using POST with URLConnection?

Posted By:   Stephen_Ostermiller  
Posted On:   Tuesday, February 26, 2002 05:34 AM

Cookies are persistant data that the server wants you to store. The cookie is given to you by the server in a header like:
Set-Cookie: foo=bar; path=/; expires=Mon, 01-Jan-2001 00:00:00 GMT


To be able to support cookies, you get the "Set-Cookie" header, parse the data, store the cookie, and then send the cookies back properly.


Cookies are sent back using "Cookie" header. Cookies should be sent back to the server that set them at every request until the cookie expires.


For mor info, see the RFC.

About | Sitemap | Contact