简体   繁体   中英

How do I read the value of a cookie that comes with a cross domain image?

I've called an image that's on another domain. It's a captcha image and it comes with a cookie with a code in it that I need to be able to access in my javascript. When I view the GET request in Google dev tools I can see the cookie, it's name and value. However I can't seem to get access to it in my javascript. I need the code to send back with a request. How do I do this? From devtools: Set-Cookie captchaCookie=54497581448a....

You can't.

Information about data loaded from other origins is not generally available to JavaScript.

If you need to get the information from the cookie, then you would be better off writing some code to run on the domain serving it that provides it in the body of a text or JSON file and uses CORS to give you permission to access it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM