[Javascript] Can't get this script to write the cookie

Phillip Morgan pjmorgan at optushome.com.au
Thu May 30 23:49:42 CDT 2002


Hi,
 
I'm having problems getting this script to work. It is intended to grab
the query string from the URL and then write that to a cookie which is
later retrieved on another page. Can anyone help please....
 
 
 <script language="JavaScript">
    <!-- Hide this script from old browsers
 
 // Set the expiry date for cookie - valid for 30 days
 var expDate = new Date();
      expDate.setTime( expDate.getTime() + ( 24 * 3600 * 30000 ) );
 var qryString;
 var myId;
 var x;
 
 qryString = window.location.search;
 x = qryString.indexOf("=");
 myId = qryString.substring((x + 1),qryString.length)
 
 function setCookie( name, value ){
      var argv = setCookie.arguments;
      var argc = setCookie.arguments.length;
      var expires = (argc > 2) ? argv[2] : null;
      var Path = (argc > 3) ? argv[3] : null;
      var domain = (argc > 4) ? argv[4] : null;
      var secure = (argc > 5) ? argv[5] : false;
 
      document.cookie = name + "=" + escape (value) +
         ( ( expires == null ) ? "" : ( "; expires=" +
expires.toGMTString() ) ) +
         ( ( Path == null ) ? ""     : ( "; path=" + Path ) ) +
         ( ( domain == null ) ? "" : ( "; domain=" + domain ) ) +
         ( ( secure == true ) ? "  ; secure" : "" );
      }
 
 // Write cookie.
setCookie('QLTReferrer',myId, expDate, cookiePath );
 
// -->
</script>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20020531/15cb7b4f/attachment.htm>


More information about the Javascript mailing list