[wp-hackers] WP 2.6.3 and setcookie

Claudio Simeone mrbrog at gmail.com
Fri Nov 7 16:21:10 GMT 2008

HI all,

I can't set cookies in WP 2.6.3 in a plugin. I'm using:

setcookie('read'.$post_ID, 1, time() + 86400, COOKIEPATH, COOKIE_DOMAIN);

The plugin count hits to single posts and set a cookie for each post
to exclude visits from the same user for one day after the first hit.
It seems that there's something that resets the all COOKIE values
(except the WP ones) - because refreshing one single post several
times, randomly, the cookie is set sometimes, but when I refresh again
the cookie is not more set.

Any ideas?

Is there a WP function that sets cookies not only for login but for
other purposes?
Or there's a different approach I can use to achieve the same goal
without cookies?

Thanks in advance.

More information about the wp-hackers mailing list