我需要读写来自JavaFx WebEngine的、安全的和不安全的cookie。
我在这个问题上花了一整天的时间,并尝试了以下方法:
- 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我希望有人能帮我。
发布于 2015-08-24 07:57:35
好吧,
如果每个人都有相同的问题,下面是解决办法:
cookie存储中的函数get(URI)被破坏,并且只在安全标志为false的情况下传递cookie。
这是不起作用的:
for(URI uri : manager.getCookieStore().getURIs()) {
for(HttpCookie httpCookie : manager.getCookieStore().get(uri)) {
System.out.println("test> " + uri.toASCIIString() + " # " + httpCookie.toString() + " - "+httpCookie.getSecure());
}
}这是工作的:
for(HttpCookie httpCookie : manager.getCookieStore().get(uri)) {
System.out.println("test> " + " # " + httpCookie.toString() + " - "+httpCookie.getSecure());
}如果需要特定cookie的URI,则必须从HttpCookie.getDomain() getter创建它。
https://stackoverflow.com/questions/32169964
复制相似问题