P
Paul Isaak
I'm new to cookies, and am having a hard time. But that's the way the
cookie... oh never mind
Can anyone point out what I've done wrong on my text page? The html is
below, and the page is at http://www.funnyjuggler.com/cookietest.html
The getcookie function doesn't seem to be storing a cookie at all, and I
don't know why
Paul
--
The Comedy & Juggling of Paul Isaak
http://www.funnyjuggler.com
1-877-852-4590
<HTML>
<HEAD>
<SCRIPT Language="JavaScript"><!--
function PaulSetDate(){
var now = new Date();
now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
return now;
}
function sethand(){
alert("running \"sethand()\"")
var hand = document.handForm.handPref.value
document.handForm.output.value= hand;
document.handForm.time.value= PaulSetDate();
Set_Cookie("favhand",hand,PaulSetDate(),path,domain,secure)
}
function Get_Cookie(name) {
var start = document.cookie.indexOf(name+"=");
var len = start+name.length+1;
if ((!start) && (name != document.cookie.substring(0,name.length)))
return
null;
if (start == -1) return null;
var end = document.cookie.indexOf(";",len);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(len,end));
}
function Set_Cookie(name,value,expires,path,domain,secure) {
document.cookie = "favhand=test;expires=" + PaulSetDate().toGMTString()
+"path=/"
//document.cookie = name + "=" +escape(value) +
//( (expires) ? ";expires=" + expires.toGMTString() : "") +
//( (path) ? ";path=" + path : "") +
//( (domain) ? ";domain=" + domain : "") +
//( (secure) ? ";secure" : "");
}
function LoadCookieINfo(){
alert(document.cookie)
document.handForm.remHand.value= Get_Cookie("fav_hand")
}
// -->
</SCRIPT>
</HEAD>
<BODY onLoad="LoadCookieINfo()">
<FORM name="handForm">
<H1> Cookie Test</H1>
I am
<Select Name="handPref" Value="Left" onChange="sethand()">
<OPTION value="left">Left <OPTION value="right">Right
</SELECT> Handed.<P>
I Like My <INPUT TYPE="Text" Name="output" size=6> Hand Better!<BR>
Cookie (to be set) Expires at <INPUT TYPE="Text" Name="time" SIZE=100>
<H2>existing cookie</H2>
I remembered that you like your <INPUT TYPE="Text" Name="remHand" size=6>
Hand Better!<BR>
Remembered Cookie Expires at <INPUT TYPE="Text" Name="remTime" SIZE=100>
</FORM>
</BODY>
</HTML>
cookie... oh never mind
Can anyone point out what I've done wrong on my text page? The html is
below, and the page is at http://www.funnyjuggler.com/cookietest.html
The getcookie function doesn't seem to be storing a cookie at all, and I
don't know why
Paul
--
The Comedy & Juggling of Paul Isaak
http://www.funnyjuggler.com
1-877-852-4590
<HTML>
<HEAD>
<SCRIPT Language="JavaScript"><!--
function PaulSetDate(){
var now = new Date();
now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
return now;
}
function sethand(){
alert("running \"sethand()\"")
var hand = document.handForm.handPref.value
document.handForm.output.value= hand;
document.handForm.time.value= PaulSetDate();
Set_Cookie("favhand",hand,PaulSetDate(),path,domain,secure)
}
function Get_Cookie(name) {
var start = document.cookie.indexOf(name+"=");
var len = start+name.length+1;
if ((!start) && (name != document.cookie.substring(0,name.length)))
return
null;
if (start == -1) return null;
var end = document.cookie.indexOf(";",len);
if (end == -1) end = document.cookie.length;
return unescape(document.cookie.substring(len,end));
}
function Set_Cookie(name,value,expires,path,domain,secure) {
document.cookie = "favhand=test;expires=" + PaulSetDate().toGMTString()
+"path=/"
//document.cookie = name + "=" +escape(value) +
//( (expires) ? ";expires=" + expires.toGMTString() : "") +
//( (path) ? ";path=" + path : "") +
//( (domain) ? ";domain=" + domain : "") +
//( (secure) ? ";secure" : "");
}
function LoadCookieINfo(){
alert(document.cookie)
document.handForm.remHand.value= Get_Cookie("fav_hand")
}
// -->
</SCRIPT>
</HEAD>
<BODY onLoad="LoadCookieINfo()">
<FORM name="handForm">
<H1> Cookie Test</H1>
I am
<Select Name="handPref" Value="Left" onChange="sethand()">
<OPTION value="left">Left <OPTION value="right">Right
</SELECT> Handed.<P>
I Like My <INPUT TYPE="Text" Name="output" size=6> Hand Better!<BR>
Cookie (to be set) Expires at <INPUT TYPE="Text" Name="time" SIZE=100>
<H2>existing cookie</H2>
I remembered that you like your <INPUT TYPE="Text" Name="remHand" size=6>
Hand Better!<BR>
Remembered Cookie Expires at <INPUT TYPE="Text" Name="remTime" SIZE=100>
</FORM>
</BODY>
</HTML>