Answer the question
In order to leave comments, you need to log in
How to get cookies for subdomain only?
There is site.com and test.site.com. Each of them has "lang" cookies. If I go to the main site and then to the test one, I get two "lang" cookies (.site.com and .test.site.com). As far as I understand, which cookie is set first, that one is shown.
Can I, while on test.site.com, receive a cookie only from a subdomain (.test.site.com)? Or set cookie priority on a test site?
Answer the question
In order to leave comments, you need to log in
Read the setcookie documentation
// Для site.com
setcookie("TestCookie", 1, time() + 3600, "/");
// или
setcookie("TestCookie", 1, time() + 3600, "/", "site.com");
// или
setcookie("TestCookie", 1, time() + 3600, "/", "www.site.com");
// Для test.site.com
setcookie("TestCookie", 1, time() + 3600, "/", "test.site.com");
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question