Reputation: 11
I'm using Indy 10 in Delphi 7. I have a TidCookieManager in a main form and I wish to copy its cookies over to another cookie manager in a separate thread, this thread obviously has access to the main form.
How do I copy those cookies?
Thanks,
David
Upvotes: 0
Views: 198
Reputation: 597941
TIdCookieManager
has a public CookieCollection
property of type TIdCookies
which provides access to the actual cookies. The cookies of one TIdCookies
can be directly copied to another TIdCookies
via its Assign()
or AddCookies()
method, eg:
// clears the dest collection before then copying cookies to it...
CookieMgrInWorkerThread.CookieCollection.Assign(CookieMgrInMainThread.CookieCollection);
// does not clear the dest collection before copying cookies to it...
CookieMgrInWorkerThread.CookieCollection.AddCookies(CookieMgrInMainThread.CookieCollection);
Either way, TIdCookies
is thread-safe, as it uses an internal TMultiReadExclusiveWriteSynchronizer
during read/write operations.
Upvotes: 3