[Solved] How to detect cookie in specific domains using $_COOKIE or any other way


Cookies are stored on client side i.e. on the browser. Also cookies are domain specific, and sub-domains can access the cookies of parent domain.
e.g.: if you have created a cookie for domain test.com then www.test.com, demo.test.com etc can access that cookie.

The reason you’re unable to access the cookie with the your domain name is because, probably you have created the cookie using localhost i.e. your second code
setcookie(‘atid’, ‘1234’, time() + 60 * 60 * 24 * 365, “https://stackoverflow.com/”, “localhost”); and trying to access it from your domain name. remove localhost from above code and then try to access it from your domain name.

use this code:

setcookie('atid', '1234', time() + 60 * 60 * 24 * 365, "https://stackoverflow.com/");

Let me know if the issue still persist.

1

solved How to detect cookie in specific domains using $_COOKIE or any other way