By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,636 Members | 1,189 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,636 IT Pros & Developers. It's quick & easy.

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

P: n/a
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!

Jul 20 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
"WeAreGoing!" <no****@reply-to-group.com> writes:
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[i].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>
---
(untested)

Good luck.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.