public Cookie [ ] cookies ( ) { List < String > newCookies = headers ( "set-cookie" ) ; if ( newCookies == null ) { return new Cookie [ 0 ] ; } List < Cookie > cookieList = new ArrayList <> ( newCookies . size ( ) ) ; for ( String cookieValue : newCookies ) { try { Cookie cookie = new Cookie ( cookieValue ) ; cookieList . add ( cookie ) ; } catch ( Exception ex ) { // ignore } } return cookieList . toArray ( new Cookie [ 0 ] ) ; }
Returns list of valid cookies sent from server . If no cookie found returns an empty array . Invalid cookies are ignored .