fookies – Export Firefox cookies to stdout in Netscape CookieJar text format

Here’s a little script I wrote to export Firefox cookies in standard text format:

#!/usr/bin/env bash
# Export Firefox cookies to stdout in Netscape CookieJar text format
# The output is suitable for use in Python's MozillaCookieJar 
# See
# http://www.cafewebmaster.com/howto-readexport-firefox-cookies-linux

# This file is released under GPL3
# Author: Mark Carter mcturra2000@yahoo.co.uk

# requires sqlite3

# determine Firefox cookie file
DIR=`ls -1dt ~/.mozilla/firefox/*.default | head -1`
CFILE=$DIR/cookies.sqlite

echo "# Netscape HTTP Cookie File
# http://www.netscape.com/newsref/std/cookie_spec.html

"

sqlite3 $CFILE <<EOF
.separator \t
--.output cookies.txt

select host, 'FALSE' as flag, path,
    case when isSecure > 0 then 'TRUE' else 'FALSE' end as secure,
    expiry, name, value  
from moz_cookies;
EOF
Advertisements

About mcturra2000

Computer programmer living in Scotland.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s