?
Solved

read cookie from other domain?

Posted on 2001-08-27
9
Medium Priority
?
238 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

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…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…
Suggested Courses

752 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