simple questions regarding the session variable

I am seriving my webapp via WEBrick.

I start a Firefox browser #1. Somewhere along the way it performs:

            @session[:key] = 'A'

I start a second Firefox browser #2. Somewhere along the way it performs:

            @session[:key] = 'B'

What I notice: the value of key in browser #1 is now B not A. I check under RAILS_ROOT/tmp/session and find a single session file only (where RAILS is using PStore to write the session data)

So whether the browsers are started concurrently, overlapping, or one at a time, the same underlying session is being used. Surely the web system is smart enough to generate different session numbers even if the client browser is on the same IP? Or am I being the idiot?

How in the heck can I generate multiple sessions one per client on WEBrick? Will that technique work under Apache or Mongrel which I intend to serve the production version of the site.

I attempted to look under

http://wiki.rubyonrails.com/rails/pages/HowtoWorkWithSessions

but that and related documentation has been down for a while.

Shane

shane wrote:

I am seriving my webapp via WEBrick.

I start a Firefox browser #1. Somewhere along the way it performs:

            @session[:key] = 'A'

I start a second Firefox browser #2. Somewhere along the way it performs:

            @session[:key] = 'B'

What I notice: the value of key in browser #1 is now B not A.

[snip]

This is happening because Rails and your browser identify the session by its _session_id value stored in the browser cookie.

Another way to do this is to turn off the browser cookies support and use my plugin for session persistent. Here each time you establish a new connection a new session is created, even within the same browser (new tab) or new browser window.

Long www.edgesoft.ca/blog/read/2 - rails articles

Thank you (and all responders). In the near future I will have to take Long's advice and move off Pstore based session files anyway which are slow.