• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSoup - Logging into a website using saved cookie data  RSS feed

 
Andrew Great
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am currently experimenting with JSoup but have come a little stuck.

Ultimately what I am trying to do is login to a website, and save the cookie data into a MySQL database, then re-visit the site using the saved cookie.

So far, I have coded this...
1, Visit the website with JSoup (as a human would do)
2, Capture cookies site by the site
3, Submit the username, password, and the cookie data back to the site
4, Check if login was successful, and if so, save cookies into a map
5, Convert map into String and save into database.

So far so good!

Then I...
1, Get the cookie data from MySQL
2, Convert the String back into a map (see below)
3, Visit the website using the cookies
4, Check if I am logged in

I would be expecting to be logged in at this point, but sadly I am not
I know for a fact the actual cookie data is correct (as being logged in), so it must be the way I pass it back.

When printing out the original cookie map it starts with{, followed by the cookie data, then ends with }
When printing out the saved cookie map it starts with{{, followed by the cookie data, then ends with }}

This is how I convert from String to Map

 
Andrew Great
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then, this is how I login...

 
Liutauras Vilda
Sheriff
Posts: 4916
334
BSD
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That could be too difficult for the beginning, so moved it to a more appropriate forum. I hope you're fine with that.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!