简体   繁体   中英

How to read a parent domain's cookie

How can I access a cookie on ".bar.com" from javascript in a webpage at "foo.bar.com"?

document.cookie (in Chrome) doesn't appear to contain this cookie even though I can see it on the Resources tab in Chrome and see that its send to the web server on a POST.

when setting the cookie you define the domain it can be read from, subdomains also work.

There also exist http-only cookies, they can't be read using javascript but you will see them in the http request.

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