Newsgroups : Borland : borland.public.delphi.internet.winsock : 2007 Mar : Re: TidCookieManager questions (threads)

www.cryer.info
Managed Newsgroup Archive

Re: TidCookieManager questions (threads)

Subject:Re: TidCookieManager questions (threads)
Posted by:"dk_sz" (dk_..@hotmail.com)
Date:Thu, 22 Mar 2007 23:45:37

>    IdHTTP.CookieManager.CookieCollection.Clear;
>    // copy shared cookies into TIdHTTP, then...
>    IdHTTP1.Get(...);
>    // now copy the new cookies into the shared manager as needed...


I have tried this solution, but I must somehow not
copy cookies in a sufficient manner. This is my code:


UpdateCookieManager(const ACookieManagerUpdate, ACookieManagerShared:
TidCookieManager);
var
  I: Integer;
  E: Integer;
  O: TIdCookieRFC2109;
  N: TIdCookieRFC2109;
begin
  ACookieManagerUpdate.CookieCollection.BeginUpdate;
  ACookieManagerCS.Acquire;
  E := ACookieManagerShared.CookieCollection.Count - 1;
  for I := 0 to E do
  begin
    O := ACookieManagerShared.CookieCollection[I];
    N := ACookieManagerUpdate.CookieCollection.Add;
    N.Assign(O);
  end;
  ACookieManagerCS.Release;
  ACookieManagerUpdate.CookieCollection.EndUpdate;
  ACookieManagerUpdate.OnNewCookie := OnNewCookie_Handler;
end;

OnNewCookie_Handler(ASender: TObject; ACookie: TIdCookieRFC2109; Var
VAccept: Boolean);
var
  TmpCookieNew: TIdCookieRFC2109;
begin
  VAccept := True;
  ACookieManagerCS.Acquire;
  TmpCookieNew := ACookieManagerShared.CookieCollection.Add;
  TmpCookieNew.Assign(ACookie);
  ACookieManagerCS.Release;
end;


best regards
Thomas Schulz

Replies:

In response to:

www.cryer.info
Managed Newsgroup Archive