0

Can I use Javascript to copy a cookie between subdomains?

I have multiple sites running on separate subdomains, but 2 of those link together and I need a cookie to copy between them. I've tried document.cookie using that new subdomain but it doesn't appear.

Scenario:

sub1.domain.com has a cookie that I want to copy to sub2.domain.com. But, it can't appear on sub3.domain.com so I'm not able to assign it specifically on domain.com

Sam
  • 31
  • 3
  • You can use the Set-Cookie header to explicitly set a different domain other than the domain to which the cookie belongs to. Refer: https://stackoverflow.com/questions/18492576/share-cookie-between-subdomain-and-domain for more details – Prashanth Wagle Feb 17 '21 at 18:06
  • 1
    Does this answer your question? [Share cookie between subdomain and domain](https://stackoverflow.com/questions/18492576/share-cookie-between-subdomain-and-domain) – Prashanth Wagle Feb 17 '21 at 18:07

0 Answers0