Problem Setting Cookies

Hi guys, having a bit of a problem with one of my scripts running on a server.

It’s a wordpress plugin, and this is the code.

        $url = get_bloginfo("url");
	$referrer = $_SERVER['HTTP_REFERER'];
	$pos = strpos($_SERVER['HTTP_REFERER'], $url);
	if ($pos == "") { $pos = "false"; }
	if ((!isset($_COOKIE["incomment_referrer"])) && ($pos == "false"))
		setcookie("incomment_referrer", $referrer, time()+3600*24, "/");

Basically, if the HTTP_REFERER is not from the blog itself (ie it’s external), a cookie is set. Or it should be.

Through debugging I have been able to enter the if statement on line 5. However, for some reason the cookie isn’t set, as when I try to access it a little later nothing is shared.

It does work on another site on my shared account, could there be a conflict in cookies? Any suggestions would be appreciated :slight_smile:

Helldesk Level 1 Response: Have you disabled cookies in your browser?


No. The thing that confuses me is the same code works on one site but not on another - it’s a Wordpress plugin