Retrieving Cookies

A

asg

I have the code below that will retrieve a cookie that was placed by
the server (ie: joes.com) that the document resides on. I want to be
able to retrieve a cookie set by another server (ie: freds.com) but I
want to retrieve it from a page served by joes.com. This code
apparently using 'document.cookie' determines the server that the
document resides on and looks for cookies from that server. Anybody
know of code that will let you determine the server?

var name = "cookie";
function getCookie(name) {
var cname = name + "=";
var dc = document.cookie;

if (dc.length > 0) {
begin = dc.indexOf(cname);
if (begin != -1) {
begin += cname.length;
end = dc.indexOf(";", begin);
if (end == -1) end = dc.length;
return unescape(dc.substring(begin,
end));
}
}
return null;
}
 
D

David Dorward

asg said:
I have the code below that will retrieve a cookie that was placed by
the server (ie: joes.com) that the document resides on. I want to be
able to retrieve a cookie set by another server (ie: freds.com) but I
want to retrieve it from a page served by joes.com.

Not possible. If you could grab cookies from other domains the user has
visited then you could gain access to those other domains with the user's
credentials.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,565
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top