({{, (RefLink[SetCookies, paclet:ref/SetCookies])[assoc] 
sets cookies with attributes specified by the association assoc, to be used by functions such as (RefLink[URLExecute, paclet:ref/URLExecute]).}, {, (RefLink[SetCookies, paclet:ref/SetCookies])[{(Subscript[assoc, 1]),(Subscript[assoc, 2]),…}]
sets a list of cookies.}})

OpenersNotesSection(Spacer1)Details

In (RefLink[SetCookies, paclet:ref/SetCookies])[assoc], the following entries can appear in the association, with the same possible values as in (RefLink[$Cookies, paclet:ref/$Cookies]):

"ExpirationDate"->(RefLink[Automatic, paclet:ref/Automatic]) indicates that a cookie is for this session only, and is not persistent.

(RefLink[SetCookies, paclet:ref/SetCookies]) can set both session cookies and persistent cookies.

All cookies that have been set are reflected in the list (RefLink[$Cookies, paclet:ref/$Cookies]). Information on persistent cookies is stored in the location specified by (RefLink[$CookieStore, paclet:ref/$CookieStore]).

OpenersPrimaryExamplesSection(Spacer1)Examples  (3)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

View currently set cookies:

$Cookies

Set cookies for a domain:

SetCookies[\[LeftAssociation]"Domain"->".wolfram.com","Path"->"/","Name"->"WR_SID","Content"->"a0696d37f9457594c0c1540","ExpirationDate"->(DateObject["Tue 9 Jun 2026 07:59:24""GMT"-5.`, DateObject[{2026,6,9},TimeObject[{7,59,24.`},TimeZone->-5.`],TimeZone->-5.`]]),"AllowSubdomains"->True,"ConnectionType"->All,"ScriptAccessible"->True\[RightAssociation]]

The cookies are stored in (RefLink[$Cookies, paclet:ref/$Cookies]) for later use:

$Cookies

OpenersExampleSection2(Spacer1)Applications  (2)

(RefLink[URLRead, paclet:ref/URLRead]) and related functions process cookie requests from the server:

$Cookies

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

If there is a matching cookie in (RefLink[$Cookies, paclet:ref/$Cookies]), no request is made by the server:

SetCookies[\[LeftAssociation]"Domain"->".wolfram.com","Path"->"/","Name"->"WR_SID","Content"->"a06993c398a5759d4621622","ExpirationDate"->(DateObject["Sun 7 Jun 2026 20:41:06""GMT"-5.`, DateObject[{2026,6,7},TimeObject[{20,41,6.`},TimeZone->-5.`],TimeZone->-5.`]]),"AllowSubdomains"->True,"ConnectionType"->All,"ScriptAccessible"->True\[RightAssociation]]

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

(RefLink[ClearCookies, paclet:ref/ClearCookies]) removes cookies:

clearedCookies=ClearCookies[All]

$Cookies

Those cookies can be later restored using (RefLink[SetCookies, paclet:ref/SetCookies]):

SetCookies[clearedCookies]

$Cookies

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[ClearCookies, paclet:ref/ClearCookies])  ▪  (RefLink[FindCookies, paclet:ref/FindCookies])  ▪  (RefLink[$Cookies, paclet:ref/$Cookies])  ▪  (RefLink[CookieFunction, paclet:ref/CookieFunction])  ▪  (RefLink[URLRead, paclet:ref/URLRead])  ▪  (RefLink[URLExecute, paclet:ref/URLExecute])}})}})

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