Pass parameter between pages in different domains (with access to both)

W

WeAreGoing!

Hello. I need to transfer an MD5 digest number between two pages on
different domains. I know this is generally not possible, but I have full
access on one domain and can insert Javascript at will into tha pages of the
other. I'd like to be able to store the number into a cookie for retrieval
by either set of pages.

I've been racking my brains for a couple of days on this one and just can't
come up with the answer.

Thanks in advance!
 
L

Lasse Reichstein Nielsen

WeAreGoing! said:
Hello. I need to transfer an MD5 digest number between two pages on
different domains. I know this is generally not possible, but I have full
access on one domain and can insert Javascript at will into tha pages of the
other.
I'd like to be able to store the number into a cookie for retrieval
by either set of pages.

Instead of trying to dodge the different-domain security settings,
which will probably not work consistently across browsers, or even
survive a patch, I would do something simpler:
Let the page that sets the cookie also load a page from the other
domain. Pass the number in the search string to that page.

You will then end up with different cookies for the different domains,
so you must keep them synchronized.

Example code:
On page in first domain:
---
function setCookieOtherDomain(cookie,returnUrl) {
location.href = "http://www.otherdomain.com/"+
"setCookieFromFirstDomain.html"+
"?cookie="+escape(cookie)"+
"&return="+escape(returnUrl);
}
---
On setCookie page in other domain:
---
<script type='text/javascript'>
function parseInput(input) { // works for search or cookies
var data = {};
if (input == "") {return data;}
var inputs = input.split("&");
for (var i in inputs) {
var parts = inputs.split("=");
data[unescape(parts[0])]=unescape(parts[1]);
}
return data;
}
var input = parseInput(location.search.substr(1));
setCookieFunction("cookie",input["cookie"]); // some function you define
location.href = input["return"];
</script>
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top