Saturday, September 27, 2008

Read Firefox cookie file

Firefox 3 stores its cookies in a cookies.sqlite file. I'm guessing its for faster access and such, but you cannot use this file if you use wget --load-cookies. So here is a script to convert the cookies.sqlite file into the old style cookies.txt file for wget to use. Or you may just want to visually inspect your cookies.
I used PHP 5.2.4.
===================================

# Replace the path with the path to your cookies.sqlite file.
$db = new PDO('sqlite:/tmp/cookies.sqlite');

$q = "select host,path,isSecure,expiry,name,value from moz_cookies";
foreach ($db->query($q) as $row)
printf("%s\tTRUE\t%s\t%s\t%d\t%s\t%s\n",$row[0],$row[1],strtoupper($row[2]),$row[3],$row[4],$row[5]);

=====================================
# php convert_cookies.php > cookies.txt

Labels:

1 Comments:

Blogger Unknown said...

This comment has been removed by a blog administrator.

November 1, 2008 at 3:40 PM  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home