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.
18 if [ -f /usr
/share
/uzbl
/examples
/configs
/cookies
]
20 file=/usr
/share
/uzbl
/examples
/configs
/cookies
22 file=.
/examples
/configs
/cookies
#useful when developing
25 if [ -d $XDG_DATA_HOME/uzbl
/cookies
]
27 cookie_dir
=$XDG_DATA_HOME/uzbl
/cookies
29 cookie_dir
=.
/examples
/data
32 which zenity
&>/dev
/null ||
exit 2
35 uri
=${uri/http:\/\/} # strip 'http://' part
42 # $1 = section (TRUSTED or DENY)
45 sed -n "/$1/,/^\$/p" $file 2>/dev
/null |
grep -q "^$host"
48 function fetch_cookie
() {
49 cookie
=`cat $cookie_dir/$host.cookie`
52 function store_cookie
() {
53 echo $cookie > $cookie_dir/$host.cookie
56 if match TRUSTED
$host
58 [ $action == PUT
] && store_cookie
$host
59 [ $action == GET
] && fetch_cookie
&& echo "$cookie"
60 elif ! match DENY
$host
62 [ $action == PUT
] && cookie
=`zenity --entry --title 'Uzbl Cookie handler' --text "Accept this cookie from $host ?" --entry-text="$cookie"` && store_cookie
$host
63 [ $action == GET
] && fetch_cookie
&& cookie
=`zenity --entry --title 'Uzbl Cookie handler' --text "Submit this cookie to $host ?" --entry-text="$cookie"` && echo $cookie