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.

Stephen Ostermiller

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.