I did some research.
- Cookies are stored in the
cookies.sqlite file in the firefox profile directory.
- The file is a sqlite database.
- The timestamp of the last access is stored in the
- The format of
lastAccessed is some
PRTime format, which is basically the unix epoch time with microseconds.
The following query will list every cookie which has not been accessed in the last 14 days.
select host, name from moz_cookies
where lastaccessed < strftime('%s000000', 'now', '-14 days')
order by lastaccessed;
I just learned some SQL for this, so it might very well be that this query can be done better.
The following query will delete all those cookies.
delete from moz_cookies
where lastaccessed < strftime('%s000000', 'now', '-14 days');
Here is a quick and dirty shell script which does the job. You will need the
sqlite3 command installed on your system.
SELECT="select host, name"
OBSOLETE="strftime('%s000000', 'now', '-$DAYS days')"
WHERE="where $LASTACCESSED < $OBSOLETE"
ORDER="order by $LASTACCESSED"
SELECTQUERY=".mode tabs\n$SELECT $FROM $WHERE $ORDER;"
DELETEQUERY="$DELETE $FROM $WHERE;"
echo $DELETEQUERY | sqlite3 cookies.sqlite