Roba
Roba

Reputation: 61

Javafx WebEngine read secured cookies

i need to read and write, secured and unsecured cookies from the JavaFx WebEngine.

I lost the whole day on this problem and tried the following ways:

Upvotes: 2

Views: 1376

Answers (1)

Roba
Roba

Reputation: 61

Okay,

if everybody have the same Issue, here is the solution:

The function get(URI) from the cookie store is broken and delivers only cookies where the secure flag is false.

This is not working:

for(URI uri : manager.getCookieStore().getURIs()) {
    for(HttpCookie httpCookie : manager.getCookieStore().get(uri)) {
        System.out.println("test> " + uri.toASCIIString() + " # " + httpCookie.toString() + " - "+httpCookie.getSecure());
    }
}

This is working:

for(HttpCookie httpCookie : manager.getCookieStore().get(uri)) {
    System.out.println("test> " + " # " + httpCookie.toString() + " - "+httpCookie.getSecure());
}

If you need the URI for a specific cookie, you have to create it from the HttpCookie.getDomain() getter.

Upvotes: 3

Related Questions