Note: Advice in this article will only work for JxBrowser 6. See the corresponding article for JxBrowser 7 here.

Each CookieStorage stores cookies on a local file system in Chromium's user data directory. So, each CookieStorage depends on BrowserContext that defines where Chromium's user data folder is located. If you need to use different cookie storages for different Browser instances, then you need to configure Browser instances with different BrowserContext instances and different Chromium's user data directories.

Browser instances with same BrowserContext instance will share the cookies.

The following code demonstrates how to create two Browser instances that don't share cookies: 

Browser browserOne = new Browser(new BrowserContext("C:\\MyUserData1"));
Browser browserTwo = new Browser(new BrowserContext("C:\\MyUserData2"));

To access CookieStorage of Browser instance use the browser.getCookieStorage() method. Using CookieStorage you can get, modify, and delete cookies. When you modify cookies you must save changes using the method. For example: 

CookieStorage cookieStorage = browser.getCookieStorage();
cookieStorage.setSessionCookie("http://www.a<span class="fr-marker" data-id="0" data-type="false" style="display: none; line-height: 0;"></span><span class="fr-marker" data-id="0" data-type="true" style="display: none; line-height: 0;"></span>.com", "name1", "value1", "", "/", false, false);;

JxBrowser supports cookies. Cookies are stored in Chromium user data directory (persistent cookies) and application memory (session cookies). If you delete Chromium user data directory, then all persistent cookies will be removed. Session cookies will be removed automatically when corresponding application terminates. Apart from persistent and session cookies, JxBrowser supports secure and http-only cookies.

Getting All Cookies 

List<Cookie> cookies = cookieStorage.getAllCookies();
for (Cookie cookie : cookies) {
    System.out.println("cookie = " + cookie);

Getting All Cookies by URL 

List<Cookie> cookies = cookieStorage.getAllCookies("");
for (Cookie cookie : cookies) {
    System.out.println("cookie = " + cookie);

Creating a Cookie 

// Create and add new cookie
final int oneHourInMilliseconds = 36000000;
final int microsecondsOffset = 1000;
// Cookie will be alive during one hour starting from now
long expirationTimeInMicroseconds = (System.currentTimeMillis() + 
        oneHourInMilliseconds) * microsecondsOffset;
cookieStorage.setCookie("", "mycookie", 
        "myvalue", "", "/", expirationTimeInMicroseconds, 
        false, false);;

Creating a Session Cookie 

// Create and add new session cookie
cookieStorage.setSessionCookie("", "mycookie", 
        "myvalue", "", "/", false, false);;

Deleting All Cookies 

int numberOfDeletedCookies = cookieStorage.deleteAll();;

Deleting a Cookie 

List<Cookie> cookies = cookieStorage.getAllCookies();
for (Cookie cookie : cookies) {
    boolean success = cookieStorage.delete(cookie);