Tôi muốn đọc JSESSIONID
từ cookie org.eclipse.swt.browser.Browser
. Tôi cố gắng mở trình duyệt từ trình cắm thêm của Eclipse. Tôi đang sử dụng đoạn mã dưới đâyCách đọc cookie từ org.eclipse.swt.browser.Browser?
public static void main(String[] args)
{
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("StackOverflow");
shell.setLayout(new FillLayout());
final Browser browser = new Browser(shell, SWT.NONE);
final String url = "https://....";
browser.setUrl(url);
browser.addProgressListener(new ProgressAdapter() {
@Override
public void completed(ProgressEvent event) {
String cookieText = "cookie=" + Browser.getCookie("JSESSIONID", url);
System.out.println(cookieText);
}
});
shell.setSize(400, 300);
shell.open();
while (!shell.isDisposed())
{
if (!display.readAndDispatch())
{
display.sleep();
}
}
display.dispose();
}
Nhưng tôi không nhận được giá trị cookie.
Something như thế này: c# Get httponly cookie
Tôi đã thử đoạn mã của bạn bằng 'http: // stackoverflow.com /'. Trước đó tôi đã sử dụng bộ kiểm tra Chromes để xem cookie nào thực sự được gửi (5 tất cả trong tất cả). Nhưng dường như SWT không thể nhìn thấy tất cả chúng. Không thể tìm thấy cái nào có tên là 'prov' và hết hạn vào năm 2055. Những cái có thể thấy hết hạn vào năm 2018 mới nhất. Có thể có một sự tương tự với JSESSIONID của bạn? –