Fehérke's GitHub Site == glue between Fehérke's GitHub hosted projects

cookieclean.sh - deletes cookies, except a whitelist

Newer Mozillas have an option to permit cookies from certain site only for one session. This is closer to what I want, but still not exactly the same. I want to accept cookies from all sites and keep them all day long. Then the next day to start navigation without those cookies, excepting a few of them which I want to keep.

The cookieclean.sh script cleans up the cookies.txt files, and starting with FireFox 3 the cookies.sqlite files, leaving only those cookies I want to keep.

For cleaning cookies.sqlite file, the sqlite3 tool is needed. Its existence is not checked, I consider it part of a standard distribution, so like I not check for the existence of grep, I will not check neither for sqlite3.

Usage

This script was designed to be run from cron, so it outputs its messages to a log file. Excepting of course unexpected and unhandled errors…

It is as least communicative as possible. It does not accept any parameter and outputs nothing to the standard output or error.

Configuration

The configuration file

cookieclean.ini - sample configuration

# Cookie Clean   version 1.3   august 2008   written by Feherke
# cleans up the Mozilla cookie file removing unwanted items
# - configuration file -

# all values are subject of variable expansion :
#  - $scriptname - the name of the script without .sh extension
#  - $scriptdir - the directory where the script resides
#  - $HOME, $TEMP, ... - usual environment variables

# path to the profile directory ( deprecated, use profile key )
#mozilla=/home/master/.mozilla/default/v5rkwo4n.slt/

# path to the profile directory
# you can use multiple profile keys
profile=/home/master/.mozilla/firefox/xie5eflf.default/
profile=/home/master/.mozilla/seamonkey/e81zpwiz.default/
profile=/home/master/.phoenix/default/10z08gzf.slt/
profile=/home/master/.gnome2/epiphany/

# list of permitted hosts
okfile=${scriptdir}/cookieclean.ok

# found unpermitted hosts
badfile=${scriptdir}/cookies---.bad

# activity log
logfile=${scriptdir}/${scriptname}.log

# permitted hosts cache file
cachefile=/tmp/${scriptname}-cache.txt
cachefile3=/tmp/${scriptname}-cache3.txt

The white list is an enumeration of allowed domains. I mean, the exact domains, as set by the cookies. So no wildcard, regular expression or partial name is available.

cookieclean.ok - sample configuration

# Cookie Clean   version 1.3   august 2008   written by Feherke
# cleans up the Mozilla cookie file removing unwanted items
# - accepted hosts list -

# empty lines are discarded, use a single dash ( - ) to say no host

-
.google.com
.google.ro

tek-tips.com
.tek-tips.com
www.tek-tips.com

Versions

Plans

In meantime Mozillas’ cookie handling and the available extensions evolved, so this script became somehow deprecated. There is good chance the plans will remain plans forever.

Download

You can find the related files on GitHub in my Bash-script repository’s cookieclean directory :