Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to set a cookie after the user has agreed to the terms and conditions form?
    primarykey
    data
    text
    <p>My question is, how do I set a cookie after the user has agreed to the Terms and Conditions page? I was going to add this code </p> <pre><code>&lt;?php //Calculate 30 days in the future //seconds * minutes * hours * days + current time $inOneMonth = 60 * 60 * 24 * 30 + time(); setcookie('lastVisit', date("G:i - m/d/y"), $inOneMonth); ?&gt; </code></pre> <p>To the below code, but depending on where I put it I either break the javascript or on page refresh the cookie is set (even though the terms and conditions have not been agreed to).</p> <pre><code>&lt;?php // Get the user's ultimate destination $dest = $_GET['dest']; // Show the terms and conditions page //check for cookie if(isset($_COOKIE['lastVisit'])) $visit = $_COOKIE['lastVisit']; /* Add redirect later document.location.href='http://&lt;?php echo $dest; ?&gt;'; add redirect code later*/ else echo "No cookies present-remove this msg later"; ?&gt; &lt;HTML&gt; &lt;HEAD&gt; &lt;TITLE&gt;User Agreement&lt;/TITLE&gt; &lt;script language="javascript"&gt; function valbutton(thisform) { // validate myradiobuttons myOption = -1; for (i=thisform.myradiobutton.length-1; i &gt; -1; i--) { if (thisform.myradiobutton[i].checked) { myOption = i; } } if (myOption == -1) { alert("You must choose either YES or NO"); return false; } if (myOption == 0) { alert("You must agree to the Terms and Conditions to download"); return false; } thisform.submit(); // this line submits the form after validation } &lt;/script&gt; &lt;/HEAD&gt; &lt;BODY&gt; &lt;H1&gt; Terms and Conditions &lt;/H1&gt; &lt;P&gt;Before downloading you must agree to be bound by masking tape&lt;/P&gt; &lt;form name="myform" action="http://&lt;?php echo $dest; ?&gt;"&gt; &lt;input type="radio" value="1st value" name="myradiobutton" /&gt;NO&lt;br /&gt; &lt;input type="radio" value="2nd value" name="myradiobutton" /&gt;YES&lt;br /&gt; &lt;input type="submit" name="submitit" onclick="valbutton(myform);return false;" value="ANSWER" /&gt; &lt;/form&gt; &lt;/BODY&gt; &lt;/HTML&gt; </code></pre> <p>I'm sure this is an easy question, but I really don't know what I'm doing. Any tips are much appreciated.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload