Can subdomain.example.com set a cookie that can be read by example.com?

Yes.

If you make sure to specify that the domain is .example.com, then *.example.com and example.com can access it.

It’s that principle that allows websites that issue cookies when somebody goes to www.website.com to access cookies when someone leaves off the www, going to website.com.

EDIT: From the PHP documentation about cookies:

domain The domain that the cookie is
available. To make the cookie
available on all subdomains of
example.com then you’d set it to
‘.example.com’. The . is not required
but makes it compatible with more
browsers. Setting it to
www.example.com will make the cookie
only available in the www subdomain.
Refer to tail matching in the ยป spec
for details.
http://php.net/manual/en/function.setcookie.php

And it’s not unique to PHP.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)