Cookie Function in Wordpress

Hi there, does anyone have a knowledge about cookies in Wordpress? I set a cookie on my site but it is only working correctly when I’m logged in to wordpress daashboard. I deleted my cache and browser history but still work when logged in. Thanks

What code did you use to set the cookie?

Here’s the code:

<?php
if(is_page(1728)) {
		if(!isset($_COOKIE["test_cookie"])){
			setcookie("test_cookie", "test", time() + 3600, '/');
		}
	}
?>

Whenever you visit that page it will create a cookie. That page has a unique phone number. What happen is once you visit that page and the visitor navigate away to another page the phone number of 1728 is supposed to follow the visitor when they click through to other pages. btw I am using Genesis theme, I use the dynamik hook box to add that code.

Does cookie works when you’re log in only?

Are you using a plugin to cache your content?

Hi there, thanks for responding to my question. been hoping for help. it’s only a server cache and I always manager to delete cache but then cookies doesn’t work. It only appear on some page. Here’s the site: http://www.renewmywindows.com/ once your’e on the homepage navigate 2 or 3 pages. Just click any page you wish then after that go to this page: http://www.renewmywindows.com/special-tv-promotion once your’e there, That’s the time cookies will trigger. See the phone number 2065081370? When you navigate to the other page that number should appear not the default number. But it is not working through all of the site pages.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.