Where does Firefox store cookies and in what format are they stored
The directory depends on your OS, but they appear to be stored in a SQLite database.
On XP, in the Application Data\Mozilla folder in C:\documents and settings.
For example, on my machine this is:
C:\Documents and Settings\\Application Data\Mozilla\Firefox\Profiles\\cookies.sqllite
It's stored in PathFromCSIDL(CSIDL_APPDATA) + "Mozilla\Firefox\Profiles\" + [[profiledirectory]] + "\" + "cookies.sqlite"
. There's also a cookies.txt file, but if will probably be empty. PathFromCSIDL
can be implemented relatively easily via the windows API.
If your goal is to access cookies programmatically, you'll probably want to do this rather than hard-coding paths. Note that [[profiledirectory]]
varies and there may be more than one profile and thus more than one directory, each profile/directory having its own cookies.
Note that in Firefox 3.5, cookies.sqlite is locked exclusively by Firefox, so you have to make a copy of it before reading.
Also, cookies.sqlite may not be flushed to disk until Firefox exits, so you can't assume that the file on disk contains the cookies you need if Firefox is still running.