I'm setting a cookie in php:
setcookie('testcookie[test_id]', "testvalue", (time()+(60*60*24*31)), "/", ".".$_SERVER['SERVER_NAME'],"1");
My live site domain value is like ".examplelive.com" and the test site is similar but shorter, e.g. ".example.com".
Here is the funny thing: The cookie is set fine, both on my testing server and live server. On my testing server, I can see both cookies, the cookie is duplicated!
So, for example when I navigate from my live server to my testing server, the cookies is duplicated and I can see both live and testing versions when browsing the test stie in Chrome. In FireFox, I only see one copy of the cookie in either site, which is desired result.
I have an entry in /etc/hosts on my machine to direct ".example.com" to my test site.
So, am I doing something wrong in how I'm setting cookies, or is this a quirk of Chrome?
Thanks to Barmar for pointing out the possibility of the test site loading a resource (e.g. image) from the live site. That was indeed what was happening and I'd missed it.
Interestingly, the difference in Chrome vs. FireFox in how 'inspect' shows cookies remains. The cookie from the live site shows under the test domain when 'inspect'ing cookies in Chrome, but not FireFox.