• 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

Cookie Path does not set properly

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am running 2 different applications on the same server domain, but they are both using the same js function to create the cookie. If I set the cookie through javascript in application 1 as mentioned in the code below, the cookie will have the following information.

Name: a_Cookie
Value: 1
Host: localhost
Path: /

When I try to set the same cookie in application 2, a new cookie is created with the following information.

Name: a_Cookie
Value: 2
Host: localhost
Path: /app2

How do I get it so that both applications update the same cookie and not create separate cookies? Is there a way?

Please see the JS code below

JS function



App1 JS call



App2 JS call



Any help is very much appreciated!

Thanks,

Juan
 
Sheriff
Posts: 9708
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can use the window.location to find which app is running in your JS and then create the cookie accordingly (since the two applications are running on the same server so they must have a different context path which you can use for your advantage)...
reply
    Bookmark Topic Watch Topic
  • New Topic