Click to See Complete Forum and Search --> : cookie question
mikehd
02-25-2003, 03:11 PM
All right, I've been using js for a few years now, but never really got into using cookies, no need. Now, I need. I can create cookies and access them from the htm pages, but what i need is to access the info from a server.
This is for a cd, and when you finish using it, you connect an internet page, and this page would read the cookie that was set during the cd use (info from a test).
I keep getting Access denied.
Any ideas are greatly appreciated in advance.
Cheers:
:confused:
Nevermore
02-25-2003, 03:17 PM
You can't read a cookie with javascript unless that domain set the cookie.
mikehd
02-25-2003, 03:22 PM
well, that makes it simple: It can't be done.
That was the way it was looking to me, I was just hoping there was something I hadn't seen.
Ahhh well..........
Charles
02-25-2003, 03:25 PM
Originally posted by cijori
You can't read a cookie with javascript unless that domain set the cookie. Sure you can. You just need to set the cookie's "domain" parameter. See http://developer.netscape.com/docs/manuals/js/client/jsref/cookies.htm and http://developer.netscape.com/docs/manuals/js/client/jsref/document.htm#1193577.
Nevermore
02-25-2003, 03:27 PM
I stand corrected. Thankyou Charles.
mikehd
02-25-2003, 03:32 PM
Great!!
Thanks for the links!!
mikehd
02-26-2003, 08:50 AM
OK, I found documentation on setting the domain and did so, but this still does not work. this is the code:
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;
}
OK then I set the cookie here:
setCookie("counter", visits, now, "/", "mydomain.com");
with 'visits' and 'now' being variables.
This is code in the top frame htm page that is located on my hard drive, I have the page that needs to read this cookie in the second frame located on mydomain.com.
Yet with "mydomain.com" set in the cookie, the cookie dosen't work. If I take that part out all together, the cookie works, but cannot be read by my second frame.
What I am doin gwrong????
Cheers in advance!
mikehd
02-26-2003, 01:20 PM
?