i'm not sure what you mean
but it looks like you are trying to change the value of the cookie by doing this:
$_COOKIE['counter'] = $count;
All that's going to do is change the value for the remainder of your script...it will have no impact on the cookie stored on the user's machine. to change that value, you have to call setcookie(). I think you also have to do that either before or after you do everything else. you might want to read up on setcookie at php.net