Cross-Domain Cookies

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gsuns82
    New Member
    • Mar 2007
    • 58

    Cross-Domain Cookies

    Hi All,
    I am trying to have two webapps such as WebApp1 and WebApp2.

    1. I am setting one cookie in WebApp1 in the HttpResponse.
    2. How to read the same cookie from HttpRequest at WebApp2?

    I know it sounds weired b'coz cookies are specific to websites, we cant access it from different webapp. But i heard of CROSS-DOMAIN cookies which can be shared across multiple webapps.How to implement this requirement using CROSS-DOMAIN cookies.

    Please post your suggestions on this....

    Note: I am trying this at J2ee webapps

    Thanks In Advance,
    Sundar
  • chaarmann
    Recognized Expert Contributor
    • Nov 2007
    • 785

    #2
    I have googled for you with "cross domain cookies" and the second hit in the list was "Implementi ng Cross-Domain Cookies - Tutorialized".
    Have you read it? Why not?

    By the way, I had the same problem and I solved it by just putting an apache-server as a proxy in between. So the domain on your browser is always the same, but it will be redirected to two different URL's internally.

    Comment

    • gsuns82
      New Member
      • Mar 2007
      • 58

      #3
      Cross/Sub Domain Cookies

      Hi,
      I tried having two webapps
      (1) WebApp.domain.c om ==> here i add cookie in respose as follows

      Cookie cookie = new Cookie("namedCo okie","test");
      cookie.setDomai n(".domain.com" );
      response.addCoo kie(cookie);

      (2)WebApp1.doma in.com==>Here i tried to access the cookie as follows, but cant able to access

      Cookie[]cks = request.getCook ies();
      for(int i=0;i<cks.lengt h;i++){
      out.print("cook ie found"+cks[i].getValue());

      }

      Any idea on this?

      Comment

      Working...