Solved

read cookie from other domain?

Posted on 2001-08-27
9
233 Views
Last Modified: 2008-01-09
Is it possible to read a cookie set by another domain?
The domains are owned by the same company! If so, how?
0
Comment
Question by:sargento
  • 4
  • 4
9 Comments
 
LVL 1

Expert Comment

by:bowker
ID: 6430111
In a word, no ... cookies are sent back to a server by the browser AFTER it compares the name of the server to which it is sending a request with the name of the "covered domain" stored as part of the cookie.

So unless you can figure out (a) where the cookie file is kept, and (b) how to read that file, you can't get the value of a cookie for another domain.

If this is one company with two sites, you can set two cookies from each site  - one that the "setting" site will receive back, and one that the "other" site will receive back.  Convoluted, but depending on just exactly what you want to do, that may be the only way.

Bob.
0
 
LVL 1

Expert Comment

by:bowker
ID: 6430114
Another alternative: let all cookies be handled by one of the sites, and let the 2 servers talk to each other by FTP or via SQL ...
0
 

Author Comment

by:sargento
ID: 6430204
what if the domain that was setting the cookie, created a second cookie, setting the domain variable to the second domain? Is that possible?
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 12

Expert Comment

by:ahosang
ID: 6430215
Try:
document.cookie="cookiename=value;expires=dateinGMT;domain=domainname";
Then your other domain that is stored will be able to read the cookie
0
 

Author Comment

by:sargento
ID: 6430243
I couldn't get that to work!
0
 
LVL 1

Accepted Solution

by:
bowker earned 200 total points
ID: 6430259
SARGENTO --

That's what I meant when I suggested, "you can set two cookies from each site  - one that the "setting" site will receive back, and one that the "other" site will receive back" ...

You could also set it up so that only 1 of the sites gets designated as the "covered domain"  - it receives all cookie responses, and your two servers talk with each other by FTP or use the same database table - then both servers have access to all statistics.

One major problem with this scenario ... server 1 sets a cookie with server 2 as the covered domain ... that cookie will not be recorded until the NEXT TIME that browser sends a request to server 2.

One solution ... server 1 sets its own cookies, server 2 sets its own cookies, and both servers record relevent data in a single database table on server 1.  Now your admin scripts, running on either server but using data from the database table on server 1, can summarize things for both sites ...

The bottom line, though, is that whatever you do will probably have to be done at the server level ... for security reasons, client-side code can't access another domain's cookie data.

Bob.
0
 

Author Comment

by:sargento
ID: 6430314
How do I read all the other parameters set in a cookie? For example the domain and path of the cookie?
0
 
LVL 1

Expert Comment

by:bowker
ID: 6430345
It can't be done client-side, except for cookies that are relevent to the domain name for which the cookie was issued ... all other work will have to be done on the server using (e.g.) PHP or PERL ...

0
 

Author Comment

by:sargento
ID: 6430362
That is what i mean! Cookies that were set by my domain. I want to look at the way it stores these parameters.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Jquery 7 34
[form-control] Retain values after a POST action 21 37
modify change color of text 9 38
REST call Failing 1 15
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question