URLConnection remembers cookies, how to get rid of them?
843790May 28 2009 — edited Jun 4 2009Hi all!
I have a bit of a problem. My script needs to get html code from some webpages. For this I use the URLConnection method, and it all works fine.
But then I created code in my script that does a http POST to this site to log in, this also works. But now every time I retrieve html from the site the site remembers me as logged in. I do not want this.
I disabled the urlconnection cache, but with no luck. I did some more research, and eventually decided to snif the http data the urlconnection generates, and to my surprise this is what I found:
Cookie: ipb_stronghold=5ba84de50e0ed48a5bb22b8c40a403a2; member_id=2056; pass_hash=bfde984b76b1c33e4f2392a8f6d1518a;
This means the urlconnection object remembers cookies, and uses them in later requests to the same site?
Anyway, I don't want this so I tried this:
conn.setRequestProperty("Cookie", "");
But this method only seems to append data to the previously mentioned cookie string, instead of overwriting it.
I also searched my disk for these cookie files, but they are nowhere to be found... I am so clueless I even rebooted, and deleted my safari/firefox cache and cookies, but with no luck.
Where are these cookies? Why does urlconnection remember them? how do I get rid of them?
I have java 1.5 under OSX 10.5.7
Reinout