Cookie Keeps Expiring When It Shouldnt

Hi Guys,

I’m trying to set a cookie but it keeps expiring as soon as its made and i cant work out why. Below is my code:

//set new cookie signup
			$parts = explode(".", $_SERVER["HTTP_HOST"]);
			$parts_size = sizeof($parts);
			$domain = "." . $parts[$parts_size - 3] . "." . $parts[$parts_size - 2] . "." . $parts[$parts_size - 1];
			setcookie("site_reg", "$leadid", $expire, "/", $domain);

As you can see the cookie should last for 30 days and only expire once it has gone past the 30 days. But for some reason it expires right away. I’m using HTTPFOX (FireFox Addon) which is showing me debug and cookie information and can see the expiry of the cookie is the same time the cookie is made. Any help would be great.

Thank you!

  1. What is the value of $domain when you echo it?

  2. I assume you are aware that cookies created by php will become available only after the page is reloaded.


  1. I assume cookies are enabled in your browser

the 30 mins edit time on my previous post has expired