views:

154

answers:

1

I am using HtmlUnit headless browser to access websites.

Can the cookies sent by those websites store on my computer when I use that headless browser?

If yes, then what's the location where these cookies get saved and how can I remove it through HtmlUnit?

+1  A: 

Use HtmlUnit.removeCookie(). Typically the Cookies in HtmlUnit are created in memory and not serialized to disk.

John Feminella
Could you please tell me the lifetime of those cookies in the memory? When they get deleted? Can the webserver detects those cookies which are in memory? How can I delete those cookies?
+1 for "...created in memory..."
Since they're in memory, they'll terminate as soon as your HtmlUnit session does. They'll also get deleted if you explicitly call `removeCookie()`. The web server doesn't really "detect" cookies -- instead it asks the user agent if any cookies are stored, and HtmlUnit will respond accordingly.
John Feminella
So, if the cookies are in memory then Will HtmlUnit respond the server with cookies? When the HtmlUnit session terminates? Will it terminate when i call webclient.closeWindow()?As acc. to the HtmlUnit docs, WebClient represents a browser, so Is it represent a mutiple-windows browser (like IE7 in which we can open multiple tabs) or represen a single-window browser?
If it represents a multiple-window browser, then does the HttpSession is maintained accross multiple windows of that webclient like real browsers?
You might want to ask a separate StackOverflow question to provide a better forum for these detailed follow-ups you're asking.
John Feminella
Ok. I have posted another question at http://stackoverflow.com/questions/2081260/htmlunit-doubts-regarding-cookies-and-windowsCould you please look at that?