有没有办法从Java程序访问存储在Chrome中的Cookie [英] Is there a way to access cookies stored in Chrome from a Java program

查看:1449
本文介绍了有没有办法从Java程序访问存储在Chrome中的Cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里是我的理想情况。我使用chrome登录www.philstockworld.com。一旦登录,我启动我的java应用程序,使用刚刚存储的chrome。然后我的java应用程序去工作。所以这里是我的问题。



这是我的程序现在可以做的,我可以使用任何浏览器登录网站,然后查找PHPSESSID的值cookie并使用该值启动我的应用程序。然后我的应用程序可以做它需要的。我也可以为我的应用程序提供我的用户名和密码,并让它登录,然后存储返回的PHPSESSID cookie,并做它需要的。然而,我想要发生的是我使用浏览器登录网站,然后我的应用程序启动,并使用PHPSESSID cookie从我的浏览器会话,而不必查找和复制它。



有没有办法让我的java应用程序获取该cookie的值,而不必手动键入?

解决方案

Cookie文件的位置为:



在Linux上:

  $ HOME / .config / google-chrome / Default / Cookies 

有关其他操作系统,请参阅 chromium.org上的用户数据页。 / p>

但是,该文件以二进制格式存储,因此很难在其中加载数据。


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 login 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.

这篇关于有没有办法从Java程序访问存储在Chrome中的Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆