There is post comment box on my site.
Posting comment is handled by javascript, js posts data to php script and php does the db related stuff and shows confirmation
You need to make sure the all the parameters (except name and time depending on the cookie.) are same while Setting Cookie in Javascript and while Removing Cookie in PHP
Parameters i.e. name,path (value and expire time can be different.)
for eg.
While setting cookie in javascript if you use it like this
document.cookie = id + "=" + input_text + " ; path=/";
you set the path to "/"
then while removing cookie in php you should specifically set like this.
//remove cookie.
setcookie($id, "", time()-36000 , "/");