({{, (RefLink[CookieFunction, paclet:ref/CookieFunction]) 
is an option for (RefLink[URLRead, paclet:ref/URLRead]), (RefLink[HTTPRequest, paclet:ref/HTTPRequest]), and related functions that gives a function to apply to each cookie received when an HTTP response is received.}})

OpenersNotesSection(Spacer1)Details

(RefLink[CookieFunction, paclet:ref/CookieFunction])->f applies f to the association that represents each received cookie.

(RefLink[CookieFunction, paclet:ref/CookieFunction])->(RefLink[Automatic, paclet:ref/Automatic]) is equivalent to (RefLink[CookieFunction, paclet:ref/CookieFunction])->(RefLink[SetCookies, paclet:ref/SetCookies]).

(RefLink[CookieFunction, paclet:ref/CookieFunction])->(RefLink[None, paclet:ref/None]) effectively blocks all cookies.

The entries in the association for a given cookie are:

(RefLink[CookieFunction, paclet:ref/CookieFunction]) is effectively applied to the "Cookies" entry in an (RefLink[HTTPResponse, paclet:ref/HTTPResponse]) object.

OpenersPrimaryExamplesSection(Spacer1)Examples  (2)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

(RefLink[Echo, paclet:ref/Echo]) received cookies:

URLRead["www.wolfram.com",CookieFunction->Echo];

No cookies are set:

$Cookies

The default value of (RefLink[Automatic, paclet:ref/Automatic]) holds received cookies:

URLRead["www.wolfram.com",CookieFunction->Automatic];

Cookies are now set:

$Cookies

OpenersExampleSection2(Spacer1)Applications  (1)

ClearCookies[All]

Create a function that echoes received cookies and stores them for later use:

cookieFunc=SetCookies[Echo[#]]&

URLRead["www.wolfram.com",CookieFunction->cookieFunc]

The cookie is now stored in (RefLink[$Cookies, paclet:ref/$Cookies]):

$Cookies

On subsequent calls to the domain, the cookie will not be reset:

URLRead["www.wolfram.com",CookieFunction->cookieFunc]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[SetCookies, paclet:ref/SetCookies])  ▪  (RefLink[HTTPResponse, paclet:ref/HTTPResponse])  ▪  (RefLink[FindCookies, paclet:ref/FindCookies])  ▪  (RefLink[AppendTo, paclet:ref/AppendTo])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[HTTP Requests & Responses, paclet:guide/HTTPRequestsAndResponses])}, {▪(RefLinkPlain[Cookie Management, paclet:guide/CookieManagement])}})}})