#!/usr/bin/perl

use strict;
use warnings;
use XML::Smart;

# lookieCookies
# This script shows info about the cookies that are in the file whose name
# is given as a command-line argument. If no command-line argument is supplied,
# the file ~/Library/Cookies/Cookies.plist is used
# The file is expected to follow the XML format of Apple's Cookies.plist file
#
# Cameron Hayne (macdev@hayne.net)  February 2006

my $userCookiesFile = "$ENV{HOME}/Library/Cookies/Cookies.plist";
my $filename = scalar(@ARGV) >= 1 ? $ARGV[0]: $userCookiesFile;
print "filename: $filename\n";

my $xml = XML::Smart->new($filename);

print $xml->root, "\n";
print $xml->{plist}->nodes_keys, "\n";
print $xml->{plist}{array}->nodes_keys, "\n";
print $xml->{plist}{array}{dict}->nodes_keys, "\n";

my @dicts = $xml->{plist}{array}{dict}->nodes;
print scalar(@dicts), "\n";
foreach my $dict (@dicts)
{
    print $dict->content, "\n";
}

# <key>Created</key>
# <real>476664985</real>
# <key>Domain</key>
# <string>.reuters.com</string>
# <key>Expires</key>
# <date>2016-02-08T23:00:28Z</date>
# <key>Name</key>
# <string>WT_FPC</string>
# <key>Path</key>
# <string>/</string>
# <key>Value</key>
# <string>id=2616a9ed81a6bec40b51138333854124:lv=1139612428008:ss=
# 1139612061591</string>

