I am currently employing a headless browser called HtmlUnit in Java to interact with different websites for testing purposes. I am curious about whether cookies from these websites are actually stored on my computer during browsing sessions. If they are, I would like to understand the location where these cookies are kept and learn about the proper method to remove them using HtmlUnit. Any guidance on managing and clearing these locally saved cookies would be greatly appreciated.
Based on my experience using HtmlUnit, cookies do not get stored on disk but remain in memory during the session. This means that once you terminate or rebuild your WebClient instance, the cookies are effectively discarded. I once encountered issues with stale session data, and reinitializing the WebClient or explicitly calling clearCookies on the CookieManager helped resolve those problems. Managing cookies through the provided methods ensures that your tests run without unwanted remaining session data or login states.
htmlunit cookis live in memry, so just building a new webclient or callin clearCookies should be enuf for a clean state. works fine for me- not much to it!