Topic Path: Symbol Reference > Classes > TIdCookieManager Class > TIdCookieManager Methods > AddCookie2 Method
ContentsIndexHome
PreviousUpNext
TIdCookieManager.AddCookie2 Method

Adds a cookie to the collection managed by IdCookieManager.

procedure AddCookie2(
    ACookie: String; 
    AHost: String
);
Parameters 
Description 
ACookie 
Textual Cookie values as described in RFC 2965.
 
AHost 
Host name or address from the URI for the HTTP request. 

AddCookie2 is a procedure that creates a new TIdCookieRFC2965 Cookie class instance for the Cookie values specified in ACookie and the Domain specified in AHost. The internal implementation of AddCookie2 ensures that the Cookie is updated to reflect the values in ACookie, and sets the Domain attribute of the Cookie to AHost when no specific Domain is found in the Cookie contents. 

AddCookie2 checks that the Cookie is valid for the Domain specified in AHost prior to signalling the OnNewCookie event handler. When AHost is not a valid Domain, or the OnNewCookie event handler indicates that the Cookie has been rejected, the Cookie class instance is removed from the CookieCollection and freed.

   // add a cookie to the collection for this domain
   IdHttpClient1.CookieManager.AddCookie2('MyCookie=MyCookieValue','www.mydomain.com');
Copyright © 1993-2006, Chad Z. Hower (aka Kudzu) and the Indy Pit Crew. All rights reserved.
Post feedback to the Indy Docs Newsgroup.