This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Servlets and the fly likes Sessions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Sessions" Watch "Sessions" New topic


colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 750
I have a simple banking web application, which I'm trying to test locally.

I run the application twice, creating 2 browsers windows, and each one I log into the application under different usernames.

The problem is the session ID is the same for each user, which explains why my session beans are acting very strange.

So I have 2 questions:

1. I guess if this were a live web app with 2 users on different computers accessing the site, the session IDs would be distinct,
so how does the web app know this isn't the case, is it cause the IP address is the same, does this determine distinct sessions?

2. How can I realiably test web apps locally without getting this 'same session' problem?

Thanks for any help.
David Newton

Joined: Sep 29, 2008
Posts: 12617

Use different browsers. Some browsers will use the same session for different windows, some won't.
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

Most of the browsers store cookies of the particular web application(if the allowed), and if you open more than one window, and request the same web application, then the browsers request the server with the sessionId cookie. So ultimately, many windows, but same sessionId. So use different browsers as David indicated!

|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Hebert Coelho
Ranch Hand

Joined: Jul 14, 2010
Posts: 754

I know that the IE has an option named -nomerge (or something like that) that you will not share your session on the tabs. But i can't tell you if you session will have the same ID. You can try it! [=

[] [Full WebApplication JSF EJB JPA JAAS with source code to download] One Table Per SubClass [Web/JSF]
Soniya Ahuja
Ranch Hand

Joined: Jul 20, 2008
Posts: 83
Even in Mozilla Firefox, if you have logged in to Gmail in one browser, then accessing GMail from another browser will directly pickup the same login credentials.
IE8 Seems to be a little more confusing. In IE8, sessions are not just stored in cookies. So if you try to disable cookies, even then sessions will work and they work across different browsers as well and then there is the -nomerge that you can try.

SCJP 1.5 | SCWCD 5 | SCJP 6.0
[url][/url] - Online training for Java/JSPs and Servlets/SCJP/SCWCD
I agree. Here's the link:
subject: Sessions
It's not a secret anymore!