Reputation: 61
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:
Get the cookies from the cookie store -> here I only get cookies without the secured flag. For more information about that I have this issue: Setting a cookie using JavaFX's WebEngine/WebView
Try to get the cookies over a self written cookie store -> same issue
Try to get the cookies with javascript -> restricted through security restrictions
Try to get the cookies from the WebEngine dom -> no result
I hope someone can help me...
Upvotes: 2
Views: 1376
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