uworlds Posted September 9, 2021 Share Posted September 9, 2021 Hello, Is it possible at all that when a cookie is created, either on a subdomain or domain, that it places a copy of it on all other subdomains, compared to passing a query string from page to page with a view to achieving the same? Kind regards Link to comment Share on other sites More sharing options...
Ingolme Posted September 9, 2021 Share Posted September 9, 2021 When creating a cookie in Javascript, setting the domain component to your top level domain will make the cookie accessible to all subdomains. Here is an example: document.cookie = "username=John Doe; domain=example.com"; The above cookie will work on example.com and also subdomain.example.com. 1 Link to comment Share on other sites More sharing options...
uworlds Posted September 11, 2021 Author Share Posted September 11, 2021 Thank you so much for this, I really appreciate it! May I please ask you as well, if the subdomain is on a different IP address than the main domain (I can't get around that), will that still make the cookie available to all subdomains seen in the browser, or do I need to create a different cookie for each subdomain that has a unique IP address? Kind regards Link to comment Share on other sites More sharing options...
Ingolme Posted September 11, 2021 Share Posted September 11, 2021 The browser should only care about the domain name, I'm not aware of any IP restrictions. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now