I’m making a Java program that accesses a website, which depends on handing out cookies so I can be logged in. I’ve found out that using a CookieManager will allow my URLConnection to atleast gather these cookies, but then how do I have these cookies persist when the java program is closed?
I already have a class that manages serialization of a few variables, so how can I implement cookies into this serialization process? Java apparently doesn’t allow me to serialize CookieManagers and CookieStores by default.
You could extend CookieManager and make it implement serializable. Then use the extended CookieManager you just created.
For example: