Cross-Domain Cookies

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Angus SC2

    Cross-Domain Cookies

    Hi I am trying to set up cross domain cookies on a server I have running
    that currently has 2 domains running on it (on different IPs). Basically I
    have a forums site (using UBB threads) and I want to users to be able to use
    the forum login and password from the main site and then if they go to the
    forum site they are already logged in to that as well.

    I have tried followed this article:


    What I have done is:
    1. Put the following code at the top of the .php file where I create the
    cookie (on the forum site) and in the .php file where my login code is on
    the main site:

    /////////////////////////////////////////////////////////
    Support cross-domain cookies... */

    // If the GET variable has been set, and it differs from the cookie
    // variable, then use the get variable (and update the cookie)
    global $HTTP_COOKIE_VA RS, $HTTP_GET_VARS;
    if (isset($session id) && isset($HTTP_GET _VARS['sessionid']) &&
    ($HTTP_COOKIE_V ARS['sessionid'] != $HTTP_GET_VARS['sessionid'])) {
    SetCookie('sess ionid', $HTTP_GET_VARS['sessionid'], 0, '/', '');
    $HTTP_COOKIE_VA RS['sessionid'] = $HTTP_GET_VARS['sessionid'];
    $sessionid = $HTTP_GET_VARS['sessionid'];
    }
    //////////////////////////////////////////////////////////

    2. Set up the
    domains['domain1'] = "http://<site domain>/-$sessionid-";
    $domains['domain2'] = http://<forums domain>/-$sessionid-;
    code in an file that is "required" by all the php scripts

    3. Done the apache server stuff

    However when I do something like
    echo $domains['domain2'];
    in the file where my login code is (on the main site) the output is:
    http://<forums domain>/--
    (there is no sessionid in the URL)


    Could someone either tell me where I am going wrong or point me to another
    article that maybe explains what I need to do a bit better. I am pretty
    certian my problem is to do with teh $sessionid in step 1 above, I never set
    it to equal anything so the code in the if statement never gets carried out.
    I also just want to make sure that cross domain cookies can be used in this
    situation

    Anyway, any help would be much appriciated
    Angus


  • Angus SC2

    #2
    Re: Cross-Domain Cookies

    "Angus SC2" <a@b.com> wrote in message news:2qdbqaFtv4 c5U1@uni-berlin.de...[color=blue]
    > Hi I am trying to set up cross domain cookies on a server I have running
    > that currently has 2 domains running on it (on different IPs). Basically
    > I have a forums site (using UBB threads) and I want to users to be able to
    > use the forum login and password from the main site and then if they go to
    > the forum site they are already logged in to that as well.
    >
    > I have tried followed this article:
    > http://www.phpbuilder.com/columns/ch...28.php3?page=3
    >[/color]

    Oops, that's the 3rd page I've posted, here is the proper URL:


    Thanks
    Angus


    Comment

    Working...