Cookie session with indy

I need to find a specific site that stores the session id with indy idhttp.

I use the following code to initialize the components that 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 that when I make a request, the cookie is not sent. What I need to do to send a cookie-witch contains a session identifier. Thanks

+6
source share
2 answers

If the cookie is not sent back to new requests, either TIdCookieManager rejected the cookie when it was received, or does not match the accepted cookie for new requests. Can you show the actual Set-Cookie response headers that send cookies and the URL (s) that you think cookies do not send correctly? Have you confirmed that after receiving a cookie, it actually ends with TIdCookieManager before sending a new request?

What version of Indy are you using? Until 2011, earlier versions of Indy 10 did disrupt the processing of cookies, which were mostly unusable. But at the beginning of 2011, IdCookieManager.pas and IdCookie.pas were completely rewritten from scratch, and since May 2011 they worked correctly, and I did not see any new messages about the abuse of cookies.

+6
source

Is there a problem with cookies that do not have the DOMAIN property? The IdCookie that ships with DXE2 cannot parse cookies that DO NOT have the MAX-AGE property, have the EXPIRES property, and do not have the DOMAIN property. See IdCookie.pas 675, where S has an unexpected value (left from parsing the expires property).

0
source

Source: https://habr.com/ru/post/907079/


All Articles