X
Tap here to go to the mobile version of the site.

Support Forum

What do cookie permission values mean in permissions.sqlite?

Posted

I want to export my cookie permissions either through a WebExtension or a script outside of Firefox.

I'm looking at the `moz_perms` table in my permissions.sqlite, and I see three values for `permission` for entries of `type` "cookie":

  • 1: Keep cookies permanently
  • 2: Block all cookies
  • 8: Keep cookies for session

As I review the Firefox codebase, I see the following in nsIPermissionManager.idl:

 const uint32_t EXPIRE_NEVER = 0;
 const uint32_t EXPIRE_SESSION = 1;
 const uint32_t EXPIRE_TIME = 2;
 const uint32_t EXPIRE_POLICY = 3;

Obviously, that doesn't match up at all, so I'm probably looking at the wrong thing. I've been a user of Self-destructing cookies if that makes any difference.

Where can I find code or documentation on meaning of the `permission` field for entries of `type` "cookie" in the `moz_perms` table of permissions.sqlite? Is there a better or existing means of exporting cookie settings like this?

I want to export my cookie permissions either through a WebExtension or a script outside of Firefox. I'm looking at the `moz_perms` table in my permissions.sqlite, and I see three values for `permission` for entries of `type` "cookie": * 1: Keep cookies permanently * 2: Block all cookies * 8: Keep cookies for session As I review the Firefox codebase, I see the following in [https://dxr.mozilla.org/mozilla-central/rev/eddbfdc38cbc0d25be44ea92588126db3d0b9a78/netwerk/base/nsIPermissionManager.idl#64 nsIPermissionManager.idl]: const uint32_t EXPIRE_NEVER = 0; const uint32_t EXPIRE_SESSION = 1; const uint32_t EXPIRE_TIME = 2; const uint32_t EXPIRE_POLICY = 3; Obviously, that doesn't match up at all, so I'm probably looking at the wrong thing. I've been a user of [https://addons.mozilla.org/en-US/firefox/addon/self-destructing-cookies/ Self-destructing cookies] if that makes any difference. Where can I find code or documentation on meaning of the `permission` field for entries of `type` "cookie" in the `moz_perms` table of permissions.sqlite? Is there a better or existing means of exporting cookie settings like this?

Modified by sondrak

Additional System Details

Application

  • User Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:56.0) Gecko/20100101 Firefox/56.0

More Information

Question owner

This does what I want, but I still was hoping to reference the code or documentation:

sqlite3 -csv permissions.sqlite '
select "origin",
   CASE
     WHEN permission = 1 THEN "allow"
     WHEN permission = 2 THEN "block"
     WHEN permission = 8 THEN "allow for session"
     ELSE permission
   END
from moz_perms where type == "cookie"
'
This does what I want, but I still was hoping to reference the code or documentation: sqlite3 -csv permissions.sqlite ' select "origin", CASE WHEN permission = 1 THEN "allow" WHEN permission = 2 THEN "block" WHEN permission = 8 THEN "allow for session" ELSE permission END from moz_perms where type == "cookie" '

Modified by sondrak

Question owner

Man I wish this used Markdown!

Man I wish this used Markdown!

Modified by sondrak

jscher2000
  • Top 10 Contributor
8688 solutions 71014 answers

Sorry, it's old wiki syntax here.

Regarding an extension, I'm not sure there is an API to read out the site permissions, so you may be stuck reading the database.

There are libraries to read databases via a webapp. I used sql.js -- a SQLite library converted to JavaScript using Emscripten -- to read the old stylish.sqlite database in this page: https://www.jeffersonscher.com/res/stylishextract.html

The sql.js library makes that data available as an array with the objects columns (has one array of headings) and values (has an array containing one array for each row). The syntax is annoying, but making it a webapp allows lots of flexibility for output.

If you are more handy with SQL and tools to handle such output (e.g., Excel) than with JavaScript, your way's probably much more efficient.

Also, on the original question, I think we know where 1 and 2 come from, but it's not clear where 8 comes from:

 const uint32_t UNKNOWN_ACTION = 0;
 const uint32_t ALLOW_ACTION = 1;
 const uint32_t DENY_ACTION = 2;
 const uint32_t PROMPT_ACTION = 3;
Sorry, it's old wiki syntax here. Regarding an extension, I'm not sure there is an API to read out the site permissions, so you may be stuck reading the database. There are libraries to read databases via a webapp. I used [https://github.com/kripken/sql.js sql.js] -- a SQLite library converted to JavaScript using Emscripten -- to read the old stylish.sqlite database in this page: https://www.jeffersonscher.com/res/stylishextract.html The sql.js library makes that data available as an array with the objects columns (has one array of headings) and values (has an array containing one array for each row). The syntax is annoying, but making it a webapp allows lots of flexibility for output. If you are more handy with SQL and tools to handle such output (e.g., Excel) than with JavaScript, your way's probably much more efficient. Also, on the original question, I think we know where 1 and 2 come from, but it's not clear where 8 comes from: const uint32_t UNKNOWN_ACTION = 0; const uint32_t '''ALLOW_ACTION = 1'''; const uint32_t '''DENY_ACTION = 2'''; const uint32_t PROMPT_ACTION = 3;
cor-el
  • Top 10 Contributor
  • Moderator
17468 solutions 157853 answers

Helpful Reply

See also: *https://dxr.mozilla.org/mozilla-release/source/netwerk/cookie/nsICookiePermission.idl