Header[] cookieHeaders = method.getResponseHeaders(HTTPConstants.HEADER_SET_COOKIE);
String customCoookiId = (String) msgContext.getProperty(Constants.CUSTOM_COOKIE_ID);
for (int i = 0; i < cookieHeaders.length; i++) {
HeaderElement[] elements = cookieHeaders[i].getElements();
for (int e = 0; e < elements.length; e++) {
HeaderElement element = elements[e];
if (Constants.SESSION_COOKIE.equalsIgnoreCase(element.getName()) ||
Constants.SESSION_COOKIE_JSESSIONID.equalsIgnoreCase(element.getName())) {
sessionCookie = processCookieHeader(element);
}
if (customCoookiId != null && customCoookiId.equalsIgnoreCase(element.getName())) {
sessionCookie = processCookieHeader(element);
}
}
}
// Overwrite old style cookies with new style ones if present
cookieHeaders = method.getResponseHeaders(HTTPConstants.HEADER_SET_COOKIE2);
for (int i = 0; i < cookieHeaders.length; i++) {
HeaderElement[] elements = cookieHeaders[i].getElements();
for (int e = 0; e < elements.length; e++) {
HeaderElement element = elements[e];
if (Constants.SESSION_COOKIE.equalsIgnoreCase(element.getName()) ||
Constants.SESSION_COOKIE_JSESSIONID.equalsIgnoreCase(element.getName())) {
sessionCookie = processCookieHeader(element);
}
if(customCoookiId!=null&&customCoookiId.equalsIgnoreCase(element.getName())){
sessionCookie = processCookieHeader(element);
}
}
}