Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
To be honest, while I know you can manipulate user-agent strings in both, I'm uncertain of whether you can use firefox cookies stored in .mozilla/.
Depending on what you're trying to do, you may be better off scripting something in Python, PHP, Ruby or Perl (I'm sure there are other languages with ways of storing Cookies). I'm particularly familiar with Python and the mechanize module (non-standard).
Firefox cookies are now stored in an sqlite database file. There's an extension or two that can export them, or you can use sqlite3. These are the notes I made for myself when I was working on the same thing:
Code:
Extracting cookies from the firefox sqlite database:
Firefox locks the database when running, so be sure to shut down first,
or else create a copy of the database and use that instead.
To get all cookies in the database, printed as-is, use this:
sqlite3 -separator $'\t' cookies.sqlite 'select * from moz_cookies'
The order of fields output from the above is:
id name value host path expiry isSecure isHttpOnly lastAccessed
But cookies.txt needs to be in this format:
domain flag path secure expiration name value
Translated to database values (field number in parens):
host(4) "0" path(5) isSecure(7) expiry(6) name(2) value(3)
(The flag field isn't stored in the database, so set it to 0)
So to get all cookies in the proper order, use:
sqlite3 -separator $'\t' cookies.sqlite 'select host,"0",path,isSecure,expiry,name,value from moz_cookies'
Or just filter the raw format command through awk:
awk -v OFS='\t' '{print $4,"0",$5,$7,$6,$2, $3}'
Once you have a cookies.txt, you can use it in wget with the --load-cookies option.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.