I want to access my Chrome stored cookies from the JavaScript console. Is this possible?
Asked
Active
Viewed 6.8k times
25
-
4What are you trying to accomplish? – Pointy Feb 26 '11 at 00:01
3 Answers
33
If you only need the cookies for the active site: Have a look at document.cookie
. It contains semicolon-separated key=value
pairs.
Edit: Note that due to security concerns you can't access cookies from a different domain. When you run something from the console, it's the equivalent of it running directly from the page, so since they don't want a spam site getting your Facebook credentials, you'll have to go to each website separately.

McKayla
- 6,879
- 5
- 36
- 48

ThiefMaster
- 310,957
- 84
- 592
- 636
-
2Does not work. Always prints undefined despite cookies being shown in BrowserDevtools > Application (Chrome) – Phil Nov 29 '20 at 20:55
22
Easiest way to go:
console.log(document.cookie);

Radium
- 564
- 3
- 17
-
2always prints undefined despite cookies being shown in BrowserDevtools > Application – Phil Nov 29 '20 at 20:53
-
@Phil, can you provide example of page, what the console prints and what do you need to see instead? Maybe the answer can be improved. On my webs, I usually see what I need to see. – Radium Jan 29 '21 at 08:10
0
Using Chrome, if you have the possibility to use other tool instead of only the Console, you can access all stored cookies and see detailed information using the tab "Resources". To do this:
- Open Developer Tools (F12)
- Click on "Resources" tab
- Expand the "Cookies" list item
- Click on the website address

Wai Ha Lee
- 8,598
- 83
- 57
- 92

Marcello
- 1,099
- 14
- 18