SetCookies

SetCookies[assoc]

sets cookies with attributes specified by the association assoc, to be used by functions such as URLExecute.

SetCookies[{assoc1,assoc2,}]

sets a list of cookies.

Details

  • In SetCookies[assoc], the following entries can appear in the association, with the same possible values as in $Cookies:
  • "Domain"domain for the cookie
    "Path"path restriction within the domain
    "Name"name of the cookie
    "Content"content of the cookie
    "ExpirationDate"when the cookie is set to expire
    "CreationDate"when the cookie was created
    "AllowSubdomains"whether to send cookies to subdomains (HostOnly)
    "ConnectionType"for what connection type the cookie should be sent (Secure)
    "ScriptAccessible"whether cookie is accessible from JavaScript etc. (HttpOnly)
  • "ExpirationDate"->Automatic indicates that a cookie is for this session only, and is not persistent.
  • SetCookies can set both session cookies and persistent cookies.
  • All cookies that have been set are reflected in the list $Cookies. Information on persistent cookies is stored in the location specified by $CookieStore.

Examples

open allclose all

Basic Examples  (1)

View currently set cookies:

Set cookies for a domain:

The cookies are stored in $Cookies for later use:

Applications  (2)

URLRead and related functions process cookie requests from the server:

If there is a matching cookie in $Cookies, no request is made by the server:

ClearCookies removes cookies:

Those cookies can be later restored using SetCookies:

Introduced in 2016
 (11.0)