Here is my ideal situation. I log into www.philstockworld.com using chrome. Once logged in I start up my java application that uses the cookies just stored by chrome. Then my java application goes to work. So here is my question.
Here is what my program can do now, I can login to the website using whatever browser I want, then look up the value of the PHPSESSID cookie and start up my app using that value. Then my app can do what it needs to. I can also supply my app with my username and password and have it log in, then store the returned PHPSESSID cookie and do what it needs to. However, what I would like to have happen is I l开发者_StackOverflow中文版ogin to the website using a browser, then my app starts and uses the PHPSESSID cookie from my browser session, without me having to look it up and copy it.
Is there a way for my java application to get the value of that cookie, without me having to manually type it in?
The location of the Cookies file is:
On Linux:
$HOME/.config/google-chrome/Default/Cookies
For other OS's see the user data page on chromium.org.
However, the file is stored in a binary format, so it's going to be hard for you to load the data within.
Joel's answer tells you where the cookie data is stored. This data is a sqlite3 database file. See this question for how to read a sqlite3 database.
I can't find how/where Chrome stores cookies, on Linux at least. Chances are that they won't be cached as simple plain text files and thus not be easily readable. You say you don't want to hard code your username/password in your java app - but why do you have do this? You could just pass them as arguments to your app?
精彩评论