wood burning stoves*
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Sessions" Watch "Sessions" New topic
Author

Sessions

colin shuker
Ranch Hand

Joined: Apr 11, 2005
Posts: 744
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
Author
Rancher

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! [=


[uaiHebert.com] [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]http://a2zjava.webs.com[/url] - Online training for Java/JSPs and Servlets/SCJP/SCWCD
http://soniyaahuja.webs.com
 
 
subject: Sessions
 
Similar Threads
session managment and StateFul Session Beans
Session persistance over 2 JVMs
compile?????
Question regarding Session Migration
Two sessions started simultaneously, updating an object