Question

Is it possible to save the cookies to a text file and use them in later requests?
Or can we define a text file as CookieStore?

Is there some good explained example?
How long are the cookies saved in programs normally and where? In the memory and for how long? Just for the time the program runs in the VM?

Do we have to fetch each cookie from the local CookieStore iterating through the list and add them manually to the text file and add these cookies later to the CookieStore again?

Was it helpful?

Solution

BasicCookieStore class shipped with HttpClient is Serializable, so its instances could be written to and read from an object stream. If you want a more elegant persistence mechanism, you will have to implement it by fetching individual cookies from the store and writing them to a persistent store.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top