Cookies and a Self-Submitting Form
Posted: Sat May 15, 2010 7:27 pm
I am using setcookie in a self-submitting form. Once the form is submitted, it sends an email and then it redirects to the next page by using a header. The problem is that the cookies aren't set for the email even though they are set (and displayed) on the next page. I've tried using the following code to reload the page before I send the email but to no avail:
setcookie("survey_username", $_POST['yourname'], time() + 31536000, '/survey/', $_SERVER['SERVER_NAME'], 0);
header("Location: ". $_SERVER['PHP_SELF']);
exit;
setcookie("survey_username", $_POST['yourname'], time() + 31536000, '/survey/', $_SERVER['SERVER_NAME'], 0);
header("Location: ". $_SERVER['PHP_SELF']);
exit;