I have a cookie “A” set at a domain at bc.test.com(all urls are changed to protect company info).
I also have a cookie “B” set at a domain of .test.com.
I also have a Javascript file hosted at bc.test.com/_include.
Now, in my host file, I have setting to point bc.test.com to a development server.
But now, when I try reading cookie “A” using document.cookie, I am not able to access the cookie. I can however read cookie “B”. I though as long as the cookie is set at the same level domain, I should be able to read it – right?
Seems to be a very simple problem, yet I am confounded by how it’s currently working.
To read a cookie, you need:
Check this first of all.
EDIT
Ex:
If your you have
bc.test.com/index.phpyou can read cookies in all paths inbc.test.com. But if you havebc.test.com/includes/index.php, you can read only cookies from folderinclude.Look this article for more information about cookie path.