Reading Javascript Cookies from a subdomain

On a subdomain -- a.test.com -- I'm trying to read the cookies set at .test.com. If I use document.cookie in JS, all i'm getting are the cookies from a.test.com. What is the syntax or route to read the cookies from .test.com?

I'm pretty certain you can read up -- from sub domain to fqdn -- but you can not read down -- fqdn to sub domain.

Thanks!

Answers:

Answer

While setting the cookies at test.com example.com, make sure that you specify the cookie domain as ".test.com" ".example.com".

For example:

your_key_name=your_key_value;domain=.example.com;expires=...

Tags

Recent Questions

Top Questions

Home Tags Terms of Service Privacy Policy DMCA Contact Us

©2020 All rights reserved.