wordpress and setcookie()
-
Hi,
I’m developing a new plugin and could do with setting a cookie to track if the user has previously visited the site. But I can’t seem to get it working.
I have read that with wordpress you need to set domain etc in the setcookie() call, but i have tried this and it still doesn’t drop a cookie. I’m even using the built in wordpress COOKIEPATH and COOKIE DOMAIN like so
$Month = 2592000 + time(); setcookie("testcookie", "cookievalue", $Month, COOKIEPATH, COOKIE_DOMAIN);i put that in a function which is called from a get_header action, so it is set before any html is printed etc. I’ve even tried calling it at wp and init but still with no joy.
I know WP has a few quirks, like the whole $() javascript thing, so maybe there is some specific way of setting your own cookie for a plugin that i’m missing?
I hope some one can shed some light on this, i spent pretty much all of yesterday trying to figure it out.
The topic ‘wordpress and setcookie()’ is closed to new replies.