Hi
This may not be the forum for cookies, but a search brought up several different forums, so since it is written in php here is my question:
This sets a cookie for each category (catid) and increments by one each time the page is loaded. The code is in a header.php page that is included by all pages on the site.
The problem is that sometimes it starts at 2. Each page is linked from the index page, which does not set a cookie. When I use *http live headers* it shows the cookie value setting at 1. But when I view cookies in firefox, some of them are 1 and some are 2. There is no further code regarding cookies in any of the pages, it is only called once in the header file. The $catid values are unique, no duplicates.
I understand cookie behavior can be random. This seems to occur in opera also. The site uses url rewrite heavily, but I don't see that in live headers so I don't *think* that is relevant.
Any ideas?
Thanks
Mike
This may not be the forum for cookies, but a search brought up several different forums, so since it is written in php here is my question:
Code:
if ($catid != "index") {
$oldCookieValue = $_COOKIE[$catid];
if ($oldCookieValue == "") {$oldCookieValue = 0;}
$cookieValue = $oldCookieValue + 1;
setcookie($catid, $cookieValue, NULL, '/');
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[URL unfurl="true"]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">[/URL]
The problem is that sometimes it starts at 2. Each page is linked from the index page, which does not set a cookie. When I use *http live headers* it shows the cookie value setting at 1. But when I view cookies in firefox, some of them are 1 and some are 2. There is no further code regarding cookies in any of the pages, it is only called once in the header file. The $catid values are unique, no duplicates.
I understand cookie behavior can be random. This seems to occur in opera also. The site uses url rewrite heavily, but I don't see that in live headers so I don't *think* that is relevant.
Any ideas?
Thanks
Mike