More
author |
Steve Losh <steve@stevelosh.com> |
date |
Fri, 16 Feb 2024 14:12:21 -0500 |
parents |
579af8ed8dcb |
children |
(none) |
#!/usr/bin/env bash
# from https://gist.githubusercontent.com/spk/5014421/raw/0055721469fe0979afbe12b602444b50608e4a74/extract_cookies.sh
# extract_cookies > ~/.cookies.txt
# wget --load-cookies=~/.cookies.txt http://mysite.com
# or
# curl --cookie ~/.cookies.txt http://mysite.com
set -euo pipefail
cleanup() {
rm -f $TMPFILE
exit 1
}
trap cleanup \
EXIT INT QUIT TERM
# This is the format of the sqlite database:
# CREATE TABLE moz_cookies (id INTEGER PRIMARY KEY, name TEXT, value TEXT, host TEXT, path TEXT,expiry INTEGER, lastAccessed INTEGER, isSecure INTEGER, isHttpOnly INTEGER);
# We have to copy cookies.sqlite, because FireFox has a lock on it
TMPFILE=`mktemp /tmp/cookies.sqlite.XXXXXXXXXX`
cat $1 >> $TMPFILE
sqlite3 -separator ' ' $TMPFILE << EOF
.mode tabs
.header off
SELECT host,
case substr(host,1,1)='.' when 0 then 'FALSE' else 'TRUE' end,
path,
case isSecure when 0 then 'FALSE' else 'TRUE' end,
expiry,
name,
value
FROM moz_cookies;
EOF
cleanup