Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing cookies from one page to another

Status
Not open for further replies.

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=&quot;JavaScript&quot; type=&quot;text/JavaScript&quot;>

function setCookie(name, value, expires, path, domain, secure) {
var curCookie = name + &quot;=&quot; + escape(value) +
((expires) ? &quot;; expires=&quot; + expires.toGMTString() : &quot;&quot;) +
((path) ? &quot;; path=&quot; + path : &quot;&quot;) +
((domain) ? &quot;; domain=&quot; + domain : &quot;&quot;) +
((secure) ? &quot;; secure&quot; : &quot;&quot;);
document.cookie = curCookie;
}

function go(){

setCookie('thisone',1);
alert(getCookie('thisone'));
window.open('
}

</script>

</HEAD>

<BODY>
<a href=&quot;javascript:go();&quot;>go</a>

</BODY>



In folder_two is the file go2.htm-

<script language=&quot;JavaScript&quot; type=&quot;text/JavaScript&quot;>

function getCookie(name) {
var dc = document.cookie;
var prefix = name + &quot;=&quot;;
var begin = dc.indexOf(&quot;; &quot; + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
} else
begin += 2;
var end = document.cookie.indexOf(&quot;;&quot;, 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=&quot;javascript:go2();&quot;>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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top