• 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

Session conflict with servers on the same IP and different ports

 
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I run servlet on localhost HttpSession.getId() returns id = A

Then I run servlet on localhost:8080 I got a new session B

Then I go back to run servlet on localhost I got a new session C!

Then I go back to run servlet on localhost:8080 I got a new session D!

The sessions seem to step on each other. Why?

 
Ranch Hand
Posts: 437
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Bruce.

Have you disabled cookies on the browser side?
 
Ranch Hand
Posts: 51
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Are you running your web server in two ports (80 and 8080) ? It seems you are calling urls on two ports.

Can you explain the way you are using these two ports?

Cheers,
Kamal
 
Sheriff
Posts: 67746
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
Those are all different domains as far as cookies are concerned. And as cookies goes, so goes the session.
 
Bruce Jin
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have 1 Tomcat on port 80 and another on port 8080.


if those are all different domains as far as cookies are concerned, why session on domain bumps session on another domain?
 
Chinmaya Chowdary
Ranch Hand
Posts: 437
Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Bruce.

if those are all different domains as far as cookies are concerned, why session on domain bumps session on another domain?



I am guessing, I have not tried this.
Session id's are created randomly. Container creates one 'session id' for one domain and another 'session id' for another domain.
 
Bruce Jin
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

ssion id's are created randomly. Container creates one 'session id' for one domain and another 'session id' for another domain.


That's what I thought. The confusion thing is that


When I run servlet on localhost I got a session A

Then I run servlet on localhost:8080 I got a new session B

Then I go back to run servlet on localhost I got a new session C! (session A disappeared!)

Then I go back to run servlet on localhost:8080 I got a new session D! session B disappeared!)

Basically when I go to one of the URLs the session Id in another Url is invalidated.

 
Bruce Jin
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using Tomcat in both ports 80 and 8080.
I am not sure if this happens in other server too.
 
reply
    Bookmark Topic Watch Topic
  • New Topic