I know from this question that Firefox 3.0 and up stores its cookies in an SQLite database. My question is: can you access this database from other desktop programs in such a way that you could add a cookie?
I realize this has security implications. However, I do not want to read them at all. I want to be able to set one cookie if possible. I don’t even want to overwrite a cookie. I just want to add it if it isn’t there already. This is sort of a personal project I’m working on for fun.
This question is mostly language agnostic. I would prefer a solution in C#, but proof of concept in any language will suffice.
Extra credit: It would be cool to set the same cookie in Internet Explorer, too
For FF3, you can access the cookies.sqlite file with any SQLite wrapper – however, check whether FF is running – it may be write-locking the file (not tested).
The database contains this:
Not sure about the primary key, it looks like it is a unix timestamp of when the cookie was created; expiry and lastAccessed are also unix timestamps, the rest is self-explanatory.
Try an
INSERT INTO moz_cookiesand see if FF becomes immediately aware of the new cookie or if it requires a restart.