NAME

HTTP::Cookies::Mozilla - Cookie storage and management for Mozilla

SYNOPSIS

use HTTP::Cookies::Mozilla;

# see "SQLite access notes"
my $file = ...; # Firefox profile dir / cookies.sqlite
my $cookie_jar = HTTP::Cookies::Mozilla->new( file => $file );

# otherwise same as HTTP::Cookies

DESCRIPTION

This package overrides the load() and save() methods of HTTP::Cookies so it can work with Mozilla cookie files. These might be stored in the user profile directory as cookies. On macOS,for instance, that's ~/Application Support/Firefox/*/cookies.sqlite.

This module should be able to work with all Mozilla derived browsers (FireBird, Camino, et alia).

Note that as of FireFox, version 3, the cookie file format changed from plain text files to SQLite databases, so you will need to have either DBI/DBD::SQLite, or the sqlite3 executable somewhere in the path. Neither one has been put as explicit dependency, anyway, so you'll get an exception if you try to use this module with a new style file but without having any of them:

neither DBI nor pipe to sqlite3 worked (%s), install either one

If your command-line sqlite3 is not in the $ENV{PATH}, you can set $HTTP::Cookies::Mozilla::SQLITE to point to the actual program to be used, e.g.:

use HTTP::Cookies::Mozilla;
$HTTP::Cookies::Mozilla::SQLITE = '/path/to/sqlite3';

Usage of the external program is supported under perl 5.8 onwards only, because previous perl versions do not support "open" in perlfunc with more than three arguments, which are safer. If you are still sticking to perl 5.6, you'll have to install DBI/DBD::SQLite to make FireFox 3 cookies work.

SQLite access notes

SQLite allows a connection to lock the database for exclusive use, and Firefox does this. If a browser is running, it probably has an exclusive lock on the database file.

If you want to add cookies that the browser will see, you need to add the cookies to the file that the browser would use. You can't add to that while the browser is running because the database is locked, but if you copy the file and try to replace it, you can miss updates that the browser makes when it closes. You have to coordinate that yourself.

If you just want to read it, you may have to copy the file to another location then use that.

Privacy settings

Firefox has a setting to erase all cookie and session data on quit. With this set, all of your cookies will disappear, even if the expiry times are in the future. Look in settings under "Privacy & Security"

Firefox tracks more information than HTTP::Cookies tracks. So far this module tracks host, path, name, value, and expiry because these are the columns common among the different modules:

  • id (no support) - primary key row

  • originAttributes (no support) - something about containers

  • name (supported)

  • value (supported)

  • host (supported)

  • path (supported)

  • expiry (supported)

  • lastAccessed (no support)

  • creationTime (no support)

  • isSecure (supported)

  • isHttpOnly (no support)

  • isBrowserElement (no support)

  • sameSite (no support)

  • rawSameSite (no support)

  • rawSameSite (no support)

SEE ALSO

SOURCE AVAILABILITY

The source is in GitHub:

https://github.com/briandfoy/http-cookies-mozilla

AUTHOR

Derived from Gisle Aas's HTTP::Cookies::Netscape package with very few material changes.

Flavio Poletti added the SQLite support.

Maintained by brian d foy, <briandfoy@pobox.com>

COPYRIGHT AND LICENSE

Parts Copyright 1997-1999 Gisle Aas.

Other parts Copyright 2018-2025 by brian d foy, <briandfoy@pobox.com>

This library is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0.