Reputation: 4326
There is a website with several subdomains.
On the main subdomain cookies are set:
@setcookie( $name, $value, $expires, '/', '.www.mysite.com');
I can see the cookie on www.mysite.com and sub1.mysite.com.
The directories are:
How can that be possible that I can't see it in the new subdomain sub2.mysite.com?
sub2.mysite.com public/sub2/index.php
Upvotes: 1
Views: 650
Reputation: 157839
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.
Subdomain should be set to .mysite.com'
path should be set, not omitted. If you want to have access to the cookie in any directory, set path to /
.
Nevertheless, the reason can be any. One have to debug their code, not asking for the possible reasons.
Upvotes: 0
Reputation: 160833
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'.
Upvotes: 3
Reputation: 10214
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
Upvotes: 1