[Javascript] Cookie dilemma - still

Phillip Morgan pjmorgan at optushome.com.au
Sun Jun 2 08:23:07 CDT 2002


Hi,
 
Yes, cookies are enabled... but...
 
dumb.. dumb.. dumb..
 
All this while I have been looking for a file in my cookies dir, when
all along the cookie has been written in index.dat.
 
A quick test by using the following simple code verified it was actually
stored...
 
    var myCookie = document.cookie;
    alert(myCookie);
 
HOWEVER...
 
The following code to retrieve the cookie, failes with "result is
undefined". (this code comes directly from my manual).
 

<script language=javascript>
function getCookie(name) { 
 var result = null;
 var myCookie = " " + document.cookie + ";";
 var searchName = " qltreferrer=";
 var startOfCookie = myCookie.indexOf(searchName);
 var endOfCookie;
 
 if (startOfCookie != -1) {
  startOfCookie += searchName.length;
  endOfCookie = myCookie.indexOf(";",startOfCookie);
  result = unescape(myCookie.substring(startOfCookie,endOfCookie));
 }
 return result;
}
 getCookie("qltreferrer");
 alert(result);
</script>
 
Once I get the value, I need to place it in a form field. If the form is
called f1, and the field is called t1, then to get it into the field the
statement would be...
 
    document.f1.t1.value = result;
 
Right?
 

-----Original Message-----
From: javascript-admin at LaTech.edu [mailto:javascript-admin at LaTech.edu]
On Behalf Of SnarfLT at aol.com
Sent: Sunday, 2 June 2002 11:00 PM
To: javascript at LaTech.edu
Subject: Re: [Javascript] Cookie dilemma - still


Do you have cookies enabled in your browser? 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20020602/ed3555ab/attachment.htm>


More information about the Javascript mailing list