Adam Tegen
Adam Tegen

Reputation: 25905

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.

Upvotes: 4

Views: 2176

Answers (1)

Niko Sams
Niko Sams

Reputation: 4414

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.

Upvotes: 3

Related Questions