# How to use the new function FindCookies?

This is a further question of this post. Actually this code from SqRoots.And this code has completed the task.

(I assume you are using Mozilla Firefox and MMA version 11.0)

Needs["DatabaseLink"];
conn=OpenSQLConnection[JDBC["SQLite",First[FileNames["cookies.sqlite",ParentDirectory[\$UserBaseDirectory]<>"\\Mozilla\\Firefox\\Profiles\\",Infinity]]]];
c=SQLExecute[conn,"select * from moz_cookies where baseDomain like '%.stackexchange.com'"];
cookie=<|"Domain"->#[[-3]],"Name"->#[[2]],"Content"->#[[3]],"Path"->#[[-2]],"ExpirationDate"->#[[-1]]|>&/@c[[;;,{2,4,5,6,7,8}]];
t=URLRead["https://mathematica.stackexchange.com/users/21532/yode?tab=favorites","Body",VerifySecurityCertificates->True,{Cookies->cookie},CharacterEncoding->"UTF-8"];
file=ExpandFileName[Export["testt.txt",t]];
Quiet[DeleteFile[StringReplace[file, "txt" -> "html"]]];
File@RenameFile[file,StringReplace[file,"txt"->"html"]]//SystemOpen


After you run this code,you will get the website like:

http://o8aucf9ny.bkt.clouddn.com/2016-09-07-17-26-33.png

This is what I want exactly.But I'm a little unhappy with the use of package DatabaseLink and that command of SQL.I think we can use the new function FindCookies to replace it.But I don't know how to realize it.

Question: How to use FindCookies to get that cookie?

## 1 Answer

[More of an extended comment]

The new cookie functionality in Mathematica 11.0 is built around CURLLink / libcurl, hence the cookie storage format is the cookiejar (Netscape cookie file) which is a plain text file with each cookie on a separate line.

Since Firefox stores the cookies in a sqlite database, they would not be directly accessible to FindCookies` and friends. Of course, there are tools available to export the cookies in this format, but that's similar in spirit to what you are already doing.

• You can show that if it can omit that command of SQL. – yode Sep 7 '16 at 14:23