Python Forum

Full Version: Cookies
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hallo,

this code to read Cookies from FireFox runs without error, but without result. In the console it shows cookies.

import sqlite3
import os

cookies =  'c:\\users\\xxx\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\xxx.default\\cookies.sqlite'

try:
    conn = sqlite3.connect(cookies)
    c = conn.cursor()
    c.execute("select host, name, value from moz_cookies")
          
    for row in c:
        host = str(row[0])
        name = str(row[1])
        value = str(row[2])
        print (host + ': ' + name + ': ' + value)
except Exception as e:
    if 'encrypted' in str(e):
        print ('encrypted')
Thank you

regards
Don't use catch all except (i.e. using general Exception).
at the moment add else part to the if in the except
except Exception as e:
    if 'encrypted' in str(e):
        print ('encrypted')
    else:
        print(e)
I guess there is some exception that you shadow and don't see it.
EDIT: yes, I get "unable to open database file"
@buran,

thank you, but there was no hidden exception.

I used Python 3 for Windows, of course with the correct UserName and Profile. For "places" I get access to the database.

regards
Hi,

Done the same thing : with result!
Try these field names in the table : moz_cookies
'select host, expiry, creationTime, lastAccessed from moz_cookies'
The date format is epoch-time, and make sure you truncate to 10 positions to get a sensible date.
(At least that is what i found)
Paul