• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

accessing cookies set by one app using another app

 
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the problem is simple, i have 2 applications deployed on the same server (2 different context roots). i use javascript to set a client-side cookie in the first app. since the 2nd app sits on the same web and application server (the same domain), the second app should be able to read the cookie set by the first app correct? no luck. any help is appreciated.

js script in my http://myserver.com/app1/
(please substitute cookie for 'kookie' since javaranch doesn't allow this specific js script comination)

2. returns nothing
and the js equivalent to read the cookie returns null (cookie does not exist). i have searched everywhere without much luck.
[ May 19, 2005: Message edited by: alan do ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you sure it's being set?
Can you read it from the first app?

Have you looked in your browser's cookie manager to see if it's there?
 
alan do
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yup, i am very sure. if i put the same test file as i have in app2 into app1 to check, it's there.
 
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Cookies can only be seen by the 'server' that sent them. This by default would be the context of your application, right?

can you do a kookie.setDomain("url_of_root_context")? cookies are available only to the context that set them and to all its sub-directories. so if your first app set the kookie, it would be avalable to it and all its sub-directories, but not the parent directory or any other directory.

If you do a kookie.setDomain("root_context") then the kookie will be available to all apps residing under that context.
 
alan do
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
neeraj,
i really appreciate the reply. i am struggling with the 'domain' concept of cookies. when i specified the 'domain' when setting up the cookie, even app1 can't find it. the underlying issue may be that the 'domain' that i see isn't what its really is (as seen by the browser/cookie).

i've tried settting the cookie w/o specifying the domain and tried to read the domain information from the cookie. per the cookie specs, the 'default' domain is set if none is specified. still, i am unable to 'read' what this 'default' domain is using JSTL although i can see the value and object reference.

the domain complication MAY be due to the applications being under Tivoli Access Manager (which does redirect after authentication). if it's at all important, both applications are struts apps, running under WAS/WSAD Test Environment. thanks for any more thought anyone can give.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic