Rev 7747 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
<article><title>Reading Firefox Cookies</title><para>Firefox stores its cookies in an SQLite database. In the directory<dir>~/Library/Application Support/Firefox/Profiles</dir> there is adefault profile, e.g. <dir>abcd2efg.default</dir>.In this directory, there is a file named <file>cookies.sqlite</file>.We can read this in R using the <r:pkg>RSQLite</r:pkg> package.We install this in the usual manner. Then we load it andcreate a connection and read the table.<r:code>library(RSQLite)drv = SQLite()cookiesDB = sqliteNewConnection(drv, "~/Library/Application Support/Firefox/Profiles/abc.default/cookies.sqlite")dbListTables(cookiesDB)cookies = dbReadTable(cookiesDB, "moz_cookies")</r:code></para><para>This gives us a data frame with 9 columns.<r:code>names(cookies)[1] "id" "name" "value" "host" "path"[2] "expiry" "lastAccessed" "isSecure" "isHttpOnly"</r:code></para><para>Now we can use cookies with <omg:pkg>RCurl</omg:pkg> by extracting thevalues from this data frame and then passing themin <omg:pkg>RCurl</omg:pkg> calls.We use the <r:arg>cookie</r:arg> argument in the form<r:code>"name=expr"</r:code>, i.e. a string.We can specify multiple cookies by separating the name=value pairsby a semi-colon.</para></article>