Reading Firefox Cookies
Firefox stores its cookies in an SQLite database. In the directory
~/Library/Application Support/Firefox/Profiles there is a
default profile, e.g. abcd2efg.default.
In this directory, there is a file named cookies.sqlite.
We can read this in R using the RSQLite package.
We install this in the usual manner. Then we load it and
create a connection and read the table.
library(RSQLite)
drv = SQLite()
cookiesDB = sqliteNewConnection(drv, "~/Library/Application Support/Firefox/Profiles/abc.default/cookies.sqlite")
dbListTables(cookiesDB)
cookies = dbReadTable(cookiesDB, "moz_cookies")
This gives us a data frame with 9 columns.
names(cookies)
[1] "id" "name" "value" "host" "path"
[2] "expiry" "lastAccessed" "isSecure" "isHttpOnly"
Now we can use cookies with RCurl by extracting the
values from this data frame and then passing them
in RCurl calls.
We use the cookie argument in the form
"name=expr", i.e. a string.
We can specify multiple cookies by separating the name=value pairs
by a semi-colon.