I must browse a certain site that keeps a session id with indy's idhttp .
i use the following code to initalize the components i need.
procedure InitSession;
begin
Initalized := True;
try
ihttp := TIdHTTP.Create(nil); //the variables are declared globally
idCookie := TIdCookieManager.Create(nil);
ihttp.ConnectTimeout := 5000;
ihttp.AllowCookies := true;
ihttp.HandleRedirects := true;
ihttp.CookieManager := idCookie;
except
Initalized := False;
end;
end;
The problem is when i am making a request the cookie isn't sent. What do i need to do in order to send the cookie witch contains the session id. Thanks
If a cookie is not being sent back in new requests, then either TIdCookieManager
rejected the cookie when it was received, or is not matching the accepted cookie to the new requests. Can you show the actual Set-Cookie
response header(s) that are sending cookies, and the URL(s) you think cookie(s) are not being sent back to correctly? Did you verify that after receiving a cookie, it actually ends up in TIdCookieManager
before sending a new request?
Which version of Indy are you using? Prior to 2011, earlier releases of Indy 10 did have broken cookie handling that was basically unusable. But in early 2011, IdCookieManager.pas
and IdCookie.pas
were complete re-written from scratch, and since May 2011 onwards have been working properly and I have not seen any new reports of cookie mishandling.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With