[thelist] How do I create a registration sheet with cookies?

Bob Haroche spambait at onpointsolutions.com
Wed Feb 9 09:51:41 CST 2005


> What I have to do is create a pop-up in which customers have to fill in
> their details. They will then be "given" a cookie (which I have to set up,
> but how?) to enable them to access our datasheets.

Below my sig is some code which I use to allow a visitor to agree to a terms
of service agreement on a web page (before entering a discussion forum) and
providing a box to check to skip this TOS page in the future -- setting a
cookie if the box is checked. With some tweaking, it should help you.

Also, if you use Dreamweaver check out the XM Cookie extension (on the MM
Exchange) which will help you write the code to write and read cookies
without knowing JS.

HTH.

------------
Regards,
Bob Haroche
O n P o i n t  S o l u t i o n s
www.OnPointSolutions.com

------ in the <head> section of the web page --------

<script language="JavaScript" type="text/javascript">
<!-- // Set cookie to skip page in future
 // Initialize variables
 expireDate = new Date
 expireDate.setYear(expireDate.getYear()+1)

 // Test for cookie and re-direct if present
 if (document.cookie != "") {
  if (document.cookie.indexOf("TOSagreed=yes") >= 0) {
  location.href = "http://www.domain.com/next-page.html";
  }
 }

 //If cookie not already present, set it if form is checked
 function setCookie() {
  if (document.TOSform.RememberMe.checked == true) {
  document.cookie = "TOSagreed=yes;expires=" + expireDate.toGMTString();
  }
 }
// -->
</script>


------ then in the form itself ---------

<form name="TOSform" method="post" action="">
  <input type="button"  value="Submit"
onClick="setCookie();window.location.href='http://www.domain.com/next-page.h
tml'">
  <p>
    <input type="checkbox" name="RememberMe" value="SkipPage">
    Skip this page in the future. </p>
</form>






More information about the thelist mailing list