# Php form cookie expire

**URL:** <https://forum.kirupa.com/t/php-form-cookie-expire/175540>\
**Category:** Uncategorized\
**Created:** [January 15, 2006, 5:29pm UTC](https://forum.kirupa.com/t/php-form-cookie-expire/175540 "2006-01-15T17:29:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![DOOJ](https://avatars.discourse-cdn.com/v4/letter/d/e274bd/32.png) [@DOOJ](https://forum.kirupa.com/u/DOOJ)\
**Post date:** [January 15, 2006, 5:29pm UTC](https://forum.kirupa.com/t/php-form-cookie-expire/175540/1 "2006-01-15T17:29:37Z")

</div>

The php form tutorial on this site doesn’t have any sort of bulk email protection. ie, a bored user could just keep going to the form and submitting, flooding my email.

I want to stop flooding by dropping a cookie once the form is submitted which would expire after 24 hours.  
I found a cookie script to do it which I place in the HEAD of the form page:

```auto
<script>
<!--
// give feedback to the respondent about the state of their submission

function AllowNoDups()
{
   var cookie_ls = document.cookie;
   if (cookie_ls.indexOf(document.location) > -1) 
   {
      alert("You've already submitted your answers. Thank you for your interest! ");
      return false;
   }
   else
       {
document.cookie = window.location.href + " from " + document.referrer + "; path=/; expires=Thu, 23-Aug-2012 00:00:01 GMT;";
      return true;
   };
   };
  //-->
</script>

```

Thing is, the date is such that it’s set manually.  
What do I need to do to modify this so that the cookie expires after 24 hours, or do I need a whole new script?

Thanks.
