Set a cookie to never expire

There is no way to set a cookie to not expire; This is not a PHP limitation, it’s just not part of the specification for cookies (http://www.faqs.org/rfcs/rfc2965.html).

Your best bet is to use a date far in the future. For example, to set a cookie that expires in ten years:

setcookie(
  "CookieName",
  "CookieValue",
  time() + (10 * 365 * 24 * 60 * 60)
);

Note that if you set a date pastΒ 2038Β in PHP, the number will wrap around and you’ll get an instant-expire cookie