Работа с куками

Получить куки:

uses
...
      IdCookieManager
      IdCookie
    ;
...
var
  FCookieManager : TIdCookieManager;
  idHTTP:TidHTTP;
...
begin
  FCookieManager := TIdCookieManager.Create;
  idHTTP:=TidHTTP.Create;
  try
    idHTTP.CookieManager := FCookieManager;
    idHTTP.AllowCookies:=True;
...

Добавить куки к запросу:

var
  s: string;
begin
    s := 'Cookie:';
    for I := 0 to FCookieManager.CookieCollection.Count -1 do
    begin
      s := s + ' ' + FCookieManager.CookieCollection.Cookies[i].CookieText+';';
    end;
    idHTTP.Request.CustomHeaders.Text := s;
  
Метки: