2 # this is an example script of how you could manage your cookies..
3 # you probably want your cookies config file in your $XDG_CONFIG_HOME ( eg $HOME/.config/uzbl/cookies)
5 # MAYBE TODO: allow user to edit cookie before saving. this cannot be done with zenity :(
6 # TODO: different cookie paths per config (eg per group of uzbl instances)
8 # TODO: correct implementation.
9 # see http://curl.haxx.se/rfc/cookie_spec.html
10 # http://en.wikipedia.org/wiki/HTTP_cookie
12 # TODO : check expires= before sending.
13 # write sample script that cleans up cookies dir based on expires attribute.
14 # TODO: check uri against domain attribute. and path also.
15 # implement secure attribute.
16 # support blocking or not for 3rd parties
17 # http://kb.mozillazine.org/Cookies.txt
19 if [ -f /usr/share/uzbl/examples/configs/cookies ]
21 file=/usr/share/uzbl/examples/configs/cookies
23 file=./examples/configs/cookies #useful when developing
26 if [ -d $XDG_DATA_HOME/uzbl/cookies ]
28 cookie_dir=$XDG_DATA_HOME/uzbl/cookies
30 cookie_dir=./examples/data
33 which zenity &>/dev/null || exit 2
36 uri=${uri/http:\/\/} # strip 'http://' part
43 # $1 = section (TRUSTED or DENY)
46 sed -n "/$1/,/^\$/p" $file 2>/dev/null | grep -q "^$host"
49 function fetch_cookie () {
50 cookie=`cat $cookie_dir/$host.cookie`
53 function store_cookie () {
54 echo $cookie > $cookie_dir/$host.cookie
57 if match TRUSTED $host
59 [ $action == PUT ] && store_cookie $host
60 [ $action == GET ] && fetch_cookie && echo "$cookie"
61 elif ! match DENY $host
63 [ $action == PUT ] && cookie=`zenity --entry --title 'Uzbl Cookie handler' --text "Accept this cookie from $host ?" --entry-text="$cookie"` && store_cookie $host
64 [ $action == GET ] && fetch_cookie && cookie=`zenity --entry --title 'Uzbl Cookie handler' --text "Submit this cookie to $host ?" --entry-text="$cookie"` && echo $cookie