Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Retrieving Cookies

Reply
Thread Tools

Retrieving Cookies

 
 
asg
Guest
Posts: n/a
 
      05-15-2006
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;
}

 
Reply With Quote
 
 
 
 
David Dorward
Guest
Posts: n/a
 
      05-15-2006
asg wrote:

> 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.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Give Request.Cookies and Response.Cookies is there any reason to use another method to use cookies? _Who ASP .Net 7 09-18-2008 07:49 PM
Query on retrieving cookies through javascript vipul Javascript 2 03-28-2008 06:26 AM
Response.Cookies vs Request.Cookies Alex Nitulescu ASP .Net 1 02-03-2005 09:43 AM
Retrieving cookies from a webserver Peter v.d. Berger Perl Misc 1 09-26-2004 11:40 PM
Persistent Cookies vs. session cookies Andy Fish Java 3 11-06-2003 10:44 AM



Advertisments