-1

I've changed the value of a cookie on the site by typing javascript:document.cookie="CName=cValue" in the URL Bar.

What script can I write to retrieve the value of cookie "CName" using a similar script right from the URL bar

2 Answers2

0

Check it out.

javascript:function getCookie(name) {var value = '; ' + document.cookie;var parts = value.split('; ' + name + '=');if (parts.length == 2) return parts.pop().split(';').shift();}alert(getCookie('CName'));
172d042d
  • 653
  • 8
  • 19
0

For something quick and dirty, that you type each time to view a cookie:

document.cookie.match(/\b__hstc=[^;]+/)

where __hstc is the name of the cookie you want.

you might also want to wrap unescape around it, and don't forget javascript: url conventions.

It works well even in devtools as well, which for some reason still has no cookie interface.

this is not a production-ready cookie method, but it gets the job done quickly in 99% of cases.

dandavis
  • 16,370
  • 5
  • 40
  • 36