Filter Cookies
Show your current list of cookies.
In[1]:=
$Cookies
Out[1]=
Clear the list of cookies.
In[2]:=
ClearCookies[All];
In[3]:=
$Cookies
Out[3]=
Create a cookie function that accepts cookies that exist only during the current session and rejects the rest. Use Echo to report whether the cookies are accepted or rejected.
In[4]:=
cookieFilter[cookie_Association] :=
If[cookie["ExpirationDate"] === Automatic,
SetCookies[Echo[cookie, "Accepted"]],
Echo[cookie, "Rejected: "]
]
In[5]:=
URLRead["amazon.com", CookieFunction -> cookieFilter]
»
»
»
»
Out[5]=
In[6]:=
URLRead["user.wolfram.com", CookieFunction -> cookieFilter]
»
»
Out[6]=
Now $Cookies only contains the cookies with no explicit expiration date.
In[7]:=
$Cookies
Out[7]=