开发者

How to extract Firefox session cookie (python language preferred)

开发者 https://www.devze.com 2023-02-22 01:52 出处:网络
I\'m trying to extract FF cookie fr开发者_JS百科om it\'s database (cookies.sqlite). However, seems that only cookies with expiration date can be found there (I am searching the one that expires when s

I'm trying to extract FF cookie fr开发者_JS百科om it's database (cookies.sqlite). However, seems that only cookies with expiration date can be found there (I am searching the one that expires when session ends). I even turned the "remember open tabs" feature of FF on. I don't get it - what's the fundamental difference between them. I can see the cookie in FF UI but cannot find on the hard drive.

Any anwers appreciated.


Session cookies are stored in the sessionstore.js file.

This file is essentially a JSON object. If you parse it, look under windows[0].cookies to get an array of the session cookies.

Typically the only fields in each session cookie are {name, host, path, value}, but occasionally you see an httpOnly parameter.


I was looking for the same thing and found this: http://blog.mithis.net/archives/python/90-firefox3-cookies-in-python I guess the right thing to do is to use the code to add another cookiejar backend


Farlan is correct the session cookies are stored in the sessionstore.js file. I created a module to load cookies from sqlite and this session file, available here: https://bitbucket.org/richardpenman/browser_cookie/

Example usage:

import requests
import browser_cookie
cj = browser_cookie.firefox()
r = requests.get('http://stackoverflow.com', cookies=cj)


session cookies probably are kept in memory and deleted once the tab/browser is closed, never entering the database.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号