-
-
Save Tblue/8c6ee7c29b683dcf3e5dad2ff1edc338 to your computer and use it in GitHub Desktop.
Hi, is using "sessionstore.jsonlz4" mandatory ?
No. However, if you skip it, you won't get any session cookies. That might or might not be an issue, depending on your use case.
I would like to use your python script to retrieve cookies but without closing Firefox.
An issue with this might be that cookies.sqlite
is locked by Firefox while it's running. Copying the DB somewhere else and reading from the copy might work around that, but it's probably not easily done on Windows (where the file can't apparently easily be copied as long as it's opened by Firefox).
Edit : I've seen that there is a backup folder (sessionstore-backups), I've modify the script like this
SESSIONSTORE_NAME = SESSIONSTOREBACKUPS_FOLDER + '\' + 'recovery.jsonlz4'
Do you think it could be a "correct" workaround to get the cookies without closing Firefox ?
If that works for you, that's great! However, be aware that the session cookies you get might not be the latest ones.
Good Day,
Am I correct that your dump-firefox-cookies.py can extract the cookies contained within a Firefox sessionstore.jsonlz4 (a json file within a custom lz4) file and output it to a sqlite file? I am using python 3.12 and have ensured the lz4 module is also installed but I am receiving the output below and was hoping you could help me to overcome the problem? Thank you for any consideration.
Traceback (most recent call last): File "/data/data/com.termux/files/home/dump-firefox-cookies.py", line 247, in sys.exit(main()) ^^^^^^ File "/data/data/com.termux/files/home/dump-firefox-cookies.py", line 243, in main write_cookie_jar(cookie_reader, args.output_file) File "/data/data/com.termux/files/home/dump-firefox-cookies.py", line 109, in write_cookie_jar for c in cookies: ^^^^^^^ File "/data/data/com.termux/files/home/dump-firefox-cookies.py", line 208, in iter yield from self._iter_session_cookies() File "/data/data/com.termux/files/home/dump-firefox-cookies.py", line 158, in _iter_session_cookies for c in data['cookies']:
~~~~^^^^^^^^^^^ KeyError: 'cookies'
Am I correct that your dump-firefox-cookies.py can extract the cookies contained within a Firefox sessionstore.jsonlz4 (a json file within a custom lz4) file and output it to a sqlite file?
Yes. Although it doesn't dump to an SQLite file, it outputs the cookies in Netscape cookie file format.
[...] I am receiving the output below and was hoping you could help me to overcome the problem?
Odd. That looks like the structure of the JSON data in sessionstore.jsonlz4
does not match my expectation. It works for me with Firefox 133.0.3, though.
- Which Firefox version are you using?
- I assume you have set Firefox to re-open windows and tabs on startup?
Hi, is using "sessionstore.jsonlz4" mandatory ?
I would like to use your python script to retrieve cookies but without closing Firefox.
Regards.
Edit : I've seen that there is a backup folder (sessionstore-backups), I've modify the script like this
SESSIONSTORE_NAME = SESSIONSTOREBACKUPS_FOLDER + '\\' + 'recovery.jsonlz4'
Do you think it could be a "correct" workaround to get the cookies without closing Firefox ?