Reputation: 1373
I have a big website using mvc pattern, it's a little bit hard to give details with links and stuff, but I want to ask a simple question.
When I set cookies like this setcookie("countviews_interview_downloads_1",'1',$this->registry->config['countviews_cookie_lifetime']);
And then check like this:
if (isset($_COOKIE['countviews_interview_downloads_1']))
{
print('msg: cookie is on interview #1');
exit;
}
A message appears that msg: cookie is on interview #1
only on the page where it has been set.
If I put this above code that checks for cookie on anyther page it does not appear, behaves like it has never been set.
Help me out please. THANKS!.
Upvotes: 0
Views: 37
Reputation: 655369
If you don’t specify any path for the cookie, a cookie is only valid for the same path. In your case that will be /interview/christmas/countdownloads
. So just set the cookie’s path to /
and it will be present for all other paths:
setcookie("countviews_interview_downloads_1",'1',$this->registry->config['countviews_cookie_lifetime'], '/')
Upvotes: 1