1
votes

I have a problem when used HttpURLConnection in Java, The connection to rest server give client cookie after authenticated. I can save the cookies from response header (Set-Cookie) after requesting and use them for next request but cookies that has !httponly flag is not available in response header (Set-Cookie).

I need the session_id cookie with !httponly flaged to be sent to next request so the connection no need to be authenticated in next request after the app exiting.

How can I save all cookies (basic cookies, secure cookies, httponly cookies) in Java just like cURL does?

2

2 Answers

0
votes

After searching for a long time, I found the solution: http://jaunt-api.com/

0
votes

I realize this question is old, but it was the first answer that came up in an internet search.

To resolve, use CookieHandler.setDefault( new CookieManager( null, CookiePolicy.ACCEPT_ALL ) ); per here: Should HttpURLConnection with CookieManager automatically handle session cookies?