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

Discussion in 'Javascript' started by WeAreGoing!, Dec 1, 2003.

  1. WeAreGoing!

    WeAreGoing! Guest

    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!
     
    WeAreGoing!, Dec 1, 2003
    #1
    1. Advertising

  2. Re: Pass parameter between pages in different domains (with accessto both)

    "WeAreGoing!" <> 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.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 -
    DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
    'Faith without judgement merely degrades the spirit divine.'
     
    Lasse Reichstein Nielsen, Dec 1, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Spongebob

    How to pass a parameter between pages?

    Spongebob, Jan 25, 2004, in forum: ASP .Net
    Replies:
    7
    Views:
    2,628
    Spongebob
    Feb 11, 2004
  2. =?iso-8859-1?q?Nils Hedstr=f6m

    Sharing login between different domains

    =?iso-8859-1?q?Nils Hedstr=f6m, Jan 24, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    343
    Steven Cheng[MSFT]
    Jan 25, 2005
  3. bharath_r

    Show Pages from two different Domains

    bharath_r, Apr 3, 2009, in forum: ASP .Net
    Replies:
    5
    Views:
    627
    Alexey Smirnov
    Apr 3, 2009
  4. Jimmy
    Replies:
    3
    Views:
    2,415
    shimmyshack
    Nov 20, 2006
  5. Ted Byers
    Replies:
    1
    Views:
    147
    Thomas 'PointedEars' Lahn
    Aug 13, 2009
Loading...

Share This Page