cesarcesar
Programmer
- Mar 5, 2003
- 30
How do you pace cookies between pages on two different folders on a server? here's my code.
in folder_one is the file go1.htm -
<script language="JavaScript" type="text/JavaScript">
function setCookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : ""
+
((path) ? "; path=" + path : ""
+
((domain) ? "; domain=" + domain : ""
+
((secure) ? "; secure" : ""
;
document.cookie = curCookie;
}
function go(){
setCookie('thisone',1);
alert(getCookie('thisone'));
window.open('
}
</script>
</HEAD>
<BODY>
<a href="javascript:go();">go</a>
</BODY>
In folder_two is the file go2.htm-
<script language="JavaScript" type="text/JavaScript">
function getCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
} else
begin += 2;
var end = document.cookie.indexOf(";", begin);
if (end == -1)
end = dc.length;
return unescape(dc.substring(begin + prefix.length, end));
}
function go2(){
alert(getCookie('thisone'));
}
</script>
</HEAD>
<BODY>
<a href="javascript:go2();">go2</a>
</BODY>
my problem is that the cookie 'thisone' gives a null value when it comes the recieving page 'go2.htm'. how do i get it to give the value i set of '1' on the first page? remember these files are in two different folders.
thank all yee masters of coding.
flashgroover
in folder_one is the file go1.htm -
<script language="JavaScript" type="text/JavaScript">
function setCookie(name, value, expires, path, domain, secure) {
var curCookie = name + "=" + escape(value) +
((expires) ? "; expires=" + expires.toGMTString() : ""
((path) ? "; path=" + path : ""
((domain) ? "; domain=" + domain : ""
((secure) ? "; secure" : ""
document.cookie = curCookie;
}
function go(){
setCookie('thisone',1);
alert(getCookie('thisone'));
window.open('
}
</script>
</HEAD>
<BODY>
<a href="javascript:go();">go</a>
</BODY>
In folder_two is the file go2.htm-
<script language="JavaScript" type="text/JavaScript">
function getCookie(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
} else
begin += 2;
var end = document.cookie.indexOf(";", begin);
if (end == -1)
end = dc.length;
return unescape(dc.substring(begin + prefix.length, end));
}
function go2(){
alert(getCookie('thisone'));
}
</script>
</HEAD>
<BODY>
<a href="javascript:go2();">go2</a>
</BODY>
my problem is that the cookie 'thisone' gives a null value when it comes the recieving page 'go2.htm'. how do i get it to give the value i set of '1' on the first page? remember these files are in two different folders.
thank all yee masters of coding.
flashgroover