To have a cookie live indefinitely after being set, you have to be sure to set a proper expiration date. If you just leave the date blank, hoping to avoid expiration altogether, then the cookie will be set as a browser session cookie, which will be deleted when the browser is closed. A god trick to have a long lived cookie would be to set its expiration date for a time very far into the future:
setcookie(\"cookie_name\",\"cookie_data\",mktime(0,0,0,1,1,2034));
This would create a cookie that will not die until January 1st, 2034. Hope this helps!