0

I wish to pass cookie value found in developer console as string programmatically using Jsoup.

I know below way to pass cookie in JSOUP

.cookies(login.cookies())

the value type is Map<String, String> var1

But I wish to string as below, how to achieve it ?

 -H 'Cookie: currency=INR; magnitude=LC; ad=3d468...' \
        -H 'Referer: https://www.valueresearchonline.com/funds/26123/motilal-oswal-flexi-cap-fund-regular-plan/' \

enter image description here

Krystian G
  • 2,842
  • 3
  • 11
  • 25
vikramvi
  • 3,312
  • 10
  • 45
  • 68
  • It's not smart to post your full cookie value used to access some kind of financial site. I censored that for you :) – Krystian G Sep 17 '22 at 23:21
  • Thanks for the help. But this financial site doesn't have any of mine sensitive info. For paid features they have started asking for id and pwd even to "free" tier users and I wish to around it :) – vikramvi Sep 19 '22 at 07:32

1 Answers1

0

As you can see on your screenshot, cookies string is sent as a header named Cookie.
If you already have the correct value you can set this header directly:

.header("Cookie", "currency=INR; magnitude=LC; ad=3d4686659c9...")
Krystian G
  • 2,842
  • 3
  • 11
  • 25
  • Thanks a zillion for your timely help, I was struck with this issue since last 3+ weeks. Can you please have a look at https://stackoverflow.com/questions/73572751/jsoup-login-cookies-are-not-working-with-sub-pages-but-only-with-home-page, while debugging this issue; I came across this new problem which actually solved my original issue. But still I'm not clear why original issue is not working as expected and I need to follow this route to get it working ? – vikramvi Sep 19 '22 at 08:26
  • I'm facing one more query after doing further debugging is, from where does this header Cookie value coming from ? I checked login response cookie value with "cookies()" function but it doesn't match with cookies seen in above screen shot – vikramvi Sep 19 '22 at 08:49
  • Kindly check new SO query related to above https://stackoverflow.com/questions/73770979/how-to-cookie-value-as-string-from-login-request-using-jsoup – vikramvi Sep 19 '22 at 09:07