Seems that the site you are scraping does multiple redirections, using cookies to identify the actual step.
In your code, you are intercepting only the Set-Cookie
header, but you are discarding previously set cookies (i.e the cookies set by response n-2).
Also, the site does a http/https switch, which you might need to consider in order to send the appropriate cookie set.