TIdCookieManager.CleanUpCookieList : List index out of bounds

Hi,

I am getting this error in this piece of code :

        for j := LCookieList.Count - 1 downto 0 do
        begin
          S := LCookieList.Cookies[j].Expires;
          if (S <> '') and (GMTToLocalDateTime(S) < Now) then
          begin
            // The Cookie has exiered. It has to be removed from the
collection
            LCookieList.Cookies[j].Free;
!!!!            LCookieList.Delete(j);
          end;

The 'LCookieList.Cookies[j].Free;' command actually removes itself from the
list so the delete operation will fail with the above mentioned error. A
solution that would always work would be to keep a reference to the object,
deleting it and then calling free. That should work either way.

---
Jens Dein
Wide Computing