Need help! - Cookies on a Survey Site
I am working on a survey.
Part of my requirements are that no one fills in the survey more than once a month.
When a user clicks complete, the page checks if there's a cookie from the site. If there is, they cannot submit (and an alert box pops up and says you already submitted). If not, the survey goes through, and they get redirected to the debriefing page.
[The 'cookie check' has to be on the submit button, because all fields need to be filled - if not, there's an error, and they have to be able to correct the error and resubmit.]
I have cookies set up so that when the user completes the survey (i.e., when they reach the "debriefing" page), they get a cookie.
However, I can only set this up with a specific expiration date. How can I fix the code so that the cookie remains for 30 days from submission, no matter what date that is?
Feel free to view the sources, and help me figure this out, please!!
The survey (checking for the cookie) is:
The debriefing (setting up the cookie) is:
var cookie_ls = document.cookie;
if (cookie_ls.indexOf(document.location) > -1)
alert("You've already submitted your answers. Thank you for your interest!");
<form method="post" action="srvyfrm.php" OnSubmit="return AllowNoDups();">
document.cookie = window.location.href + " from " + document.referrer + "; path=/; expires=Thu, 23-Aug-2012 00:00:01 GMT;";