$Cookies

$Cookies

is a global variable that contains a list of cookies to be used by functions such as URLExecute.

Details

  • $Cookies must be a list of associations, with each association representing a cookie.
  • The association for each cookie can contain the following elements:
  • "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" has value Automatic if the cookie is for the duration of the session only.
  • If not set, "Domain" is assumed to be Automatic, so that the domain is deduced from the specific URL from which the request was generated.
  • With the setting "AllSubdomains"->True, cookies are also sent to subdomains of the domain specified by "Domain".
  • If not set, "AllowSubdomains" is assumed to be Automatic, which corresponds to True if "Domain" is Automatic, and False otherwise.
  • If not set, "ConnectionType" is assumed to be All. "ConnectionType"->"HTTPS" specifies that the cookie should be sent only when an HTTPS connection is used.
  • If not set, "ScriptAccessible" is assumed to be True, indicating that web browsers should allow the cookie to be accessed using JavaScript, even if the JavaScript is on a page from another domain.
  • $Cookies can be modified using SetCookies and ClearCookies.
  • With the default setting CookieFunction->Automatic, functions like URLRead automatically append all newly received cookies to $Cookies.
  • Block[{$Cookies},] can be used to localize cookies. Block[{$Cookies,$CookieStore},] also blocks the saving of persistent cookies.

Examples

open allclose all

Basic Examples  (1)

View currently set cookies:

In[1]:=
Click for copyable input
Out[1]=

Cookies can be received and set when URL commands are executed:

In[2]:=
Click for copyable input
Out[2]=

Applications  (1)

Properties & Relations  (3)

See Also

FindCookies  SetCookies  ClearCookies  $CookieStore  CookieFunction  HTTPRequestData

Introduced in 2016
(11.0)