As you can see here http://php.net/setcookie that is the default behavior for setcookie()
function.
The path on the server in which the cookie will be available on. If set to '/', the cookie will be available within the entire domain. If set to '/foo/', the cookie will only be available within the /foo/ directory and all sub-directories such as /foo/bar/ of domain. The default value is the current directory that the cookie is being set in.
You should set your path to '/' if you want your cookies to be valid for whole domain.