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

Adds a cookie to the collection managed by IdCookieManager.

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

AddCookie is a procedure that creates a new TIdCookieRFC2109 Cookie class instance for the Cookie values specified in ACookie and the Domain specified in AHost. The internal implementation of AddCookie 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. 

AddCookie 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.AddCookie('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.