• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Cross-Domain Cookies

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are both web apps running on the same (sub) domain? If so, you can set the cookie path and domain; check the Cookie.setPath and Cookie.setDomain methods.

And no, HTTP cookies do not work across domains.
 
sundaresan ganapathy
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi lester,
I can implement this Domain and SubDomain, can you please provide more clarity on this???

Thanks,
Sundar
 
sundaresan ganapathy
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I meant, can you please add more clarity on configuration part, how to create/configure domain and subdomain in j2ee environment???

Thanks
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There isn't anything to configure, really, except for using the Cookie.setDomain method for any cookies you create. If you have web apps at a.domain.com and b.domain.com, then setDomain("domain.com") should make the cookie visible to both web apps (not sure about the details, play around to see what works). Reading the cookie spec will probably be helpful, too.
 
Bartender
Posts: 1111
Eclipse IDE Oracle VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i found it really helpful using firefox, and using the "delete single cookies" option to scroll through my cookies to see what the values were
 
sundaresan ganapathy
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I tried having two webapps
(1) WebApp.domain.com ==> here i add cookie in respose as follows

Cookie cookie = new Cookie("namedCookie","test");
cookie.setDomain(".domain.com");
response.addCookie(cookie);

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

Cookie[]cks = request.getCookies();
for(int i=0;i<cks.length;i++){
out.print("cookie found"+cks[i].getValue());

}

Any idea on this?>
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sundaresan ganapathy wrote: it sounds weired b'coz cookies


Please use real words when posting to the forums. Abbreviations such as "b'coz" in place of "because" only serve to make your posts more difficult to read and less likely to generate useful responses.

Please click this link ⇒ UseRealWords for more information.
 
I just had the craziest dream. This tiny ad was in it.
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic