I am using selenium with firefox. I am having trouble getting the http_only cookies retrieved from the code.


brings in regular cookies, but not httponly cookies. Is there a way to retrieve these cookies? Or is it really a deadend?


You can use the approach like this:

public void testHttpOnlyCookies() {
    Set<Cookie> cookies = driver.manage().getCookies();
    cookies.stream().filter(c -> c.isHttpOnly()).forEach(System.out::println);

in other words each cookie has a property that can be obtained using isHttpOnly() method. Using that one you can filter all cookies to either get httpOnly or not httpOnly.

| improve this answer | |
  • are you saying the manage.getCookies() gets everything? I didnt get everything in that call. all httponly cookies were missing in what was returned. – melchi Apr 21 at 14:24
  • Yest, it gets everything and when I prepared the example I used FireFox like you do. – Alexey R. Apr 21 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.