Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is session data thread safe?

 
Bruce Jin
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My feeling is that it is safe since only one user (one browser window) can send one request at a time.
One book says multiple browsers share one session. I can not figure it out.
Any thoughts?
Thanks.
 
Anthony Villanueva
Ranch Hand
Posts: 1055
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to the Servlet 2.3 specs:

SRV.7.7.1 Threading Issues
Multiple servlets executing request threads may have active access to a single session object at the same time. The Developer has the responsibility for synchronizing access to session resources as appropriate.
 
guo mark
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
each user own a session but not each browser.you may get a session shared by several browser source from some single page(for example you chick a hyperlink and open a new page in a new windon).
It is that you mean?
 
Bruce Jin
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
I open multiple windows and they all have different sessions.
Now I will try open new windows from a window (by click a link). Maybe these windows will share the same session.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13058
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might have multiple requests from the same window executing at the same time. For example a page with frames may generate several requests, or one that gets dynamically generated images.
Bill
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Different browser windows opened by the same user and belong to the same session is extremely common.
Just use your yahoo account, log in mail.yahoo.com, then if you click the browser icon on your desktop, you get another session, to verify it, you found you need to re-login.
However, if you open a new browser from the already-login browser window File->New->Window, you have 2 browser windows but the same session, to verify it, you found you do not need to re-login. You can do many things with the same or different pages concurrently.
[ August 19, 2002: Message edited by: Roseanne Zhang ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic