Search code examples
javabrowsercookieshtmlunit

How to delete cookies?


I want to delete cookies programmatically.

More specifically, I am using HtmlUnit with Java to automate browser operations. After performing some operations I want to clear cookies so that my subsequent operations make sense. How can I clear cookies through HtmlUnit or through Java or through any other way automatically.


Solution

  • In actual, the cookies in HtmlUnit doesn't get stored on disk until saved programmatically. They remain in the memory. From the memory they gets deleted when the HtmlUnit session expires.