Cookies And Subdomain

Setting the domain to 'www.example.com' or '.www.example.com' will make the cookie only available in the www subdomain.

If you want to make the cookie available on all subdomains of example.com (including example.com itself) then you'd set it to '.example.com'.

make sure the path is set to / so it works for the whole site, otherwise it might not work for sub directories on your site

  1. Using @ is not a wise act in general but using it in front of setcookie() is exceptionally unwise, if not to say a stronger word.

  2. Subdomain should be set to .mysite.com'

  3. path should be set, not omitted. If you want to have access to the cookie in any directory, set path to /.

  4. Nevertheless, the reason can be any. One have to debug their code, not asking for the possible reasons.