There are two domains: a.example.com example.com
example.com is the parent domain of a.example.com. Now both a.example.com and example.com may write a cookie named test_cookie. Now we have a page of a.example.com which will use javascript to read value of cookie test_cookie. Is there a way that only read the cookie set in the domain of a.example.com rather than example.com?
Maybe my question was a little unclear,
the goal i want to achieve is: 1. i want to write a function named readCookie to read the cookie with name test_cookie which: a. when there is a cookie: test_cookie under domain example.com and NO cookie test_cookie under domain a.example.com, readCookie returns null b. when there is a cookie: test_cookie under domain example.com AND ALSO a cookie test_cookie under domain a.example.com, readCookie returns the cookie value under domain a.example.com c. when there NO cookie: test_cookie under exampler.com, but there is a cookie test_cookie under domain a.example.com, readCookie returns the cookie value under domain a.example.com.