Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Using Firefox. I would like to get rid of "obsolete" cookies. By "obsolete" I mean cookies which have not been accessed by any website in the last x days.

I have searched high and low but I have not found how to do that. What I have found is, among others:

  • restrict the lifetime of all cookies (about:config -> network.cookie.lifetimePolicy).
  • whitelist or blacklist domains (firefox preferences -> privacy -> cookie exceptions).
  • delete all cookies from the last x hours (firefox history -> clear recent history).

None of that is what I want.

I want to delete all cookies which have not been accessed by any website in the last x days.

share|improve this question
Most likely, an extension is needed for this. – Hello71 Jan 4 '12 at 16:12
Not sure if this accomplishes what you want, but I have Firefox to not automatically accept cookies, and instead am prompted when cookies try to install. In the prompt dialog box, I choose to store the cookie as a "session" cookie rather than a "standard" cookie. – sawdust Jan 4 '12 at 22:50
I used this request to show the latest cookies select datetime(lastAccessSec , 'unixepoch', 'localtime') as "lastAccessTime", * from (SELECT lastAccessed/1000000 as "lastAccessSec", * FROM moz_cookies order by lastAccessed desc LIMIT 50). It runs from SQLite firefox manager. – Val Jul 22 '14 at 14:57
up vote 1 down vote accepted

The Cookie Time extension can be configured to automatically delete cookies that haven't been used for a specified time (expired). It also has a separate setting to force expire / delete all cookies that are beyond a specified age.

Cookie Time configuration screenshot

share|improve this answer

I did some research.

  1. Cookies are stored in the cookies.sqlite file in the firefox profile directory.
  2. The file is a sqlite database.
  3. The timestamp of the last access is stored in the lastAccessed column in the moz_cookies table.
  4. 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"
FROM="from moz_cookies"
OBSOLETE="strftime('%s000000', 'now', '-$DAYS days')"
WHERE="where lastaccessed < $OBSOLETE"
ORDER="order by lastaccessed"


printf '%s\n' "$SELECTQUERY" | sqlite3 cookies.sqlite
share|improve this answer
What is the '%s000000' format? I see that SELECT datetime(strftime('%s000000','now'), 'unixepoch', 'localtime') prints extreemly wiered negative time, -1413-03-01 15:07:12, whereas '%s' is fine, it produces 2014-07-22 16:01:17, which is really now. At the same time, I see that firefox uses the wierd time format. What is that? – Val Jul 22 '14 at 14:03
Ok, 000000 just means that firefox stores millions of seconds instead of seconds. So, if I want to translate the firefox time into standard epoch date (%s stands for the num of seconds since 1970), I can just divide the firefox date by 1000000. This helped me to realize this, – Val Jul 22 '14 at 14:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.