Session being overwritten by different actions

Suppose you have a controller with 2 actions that look like this

def long
session[:foo] = “bar”
sleep 15
render :nothing => true

def short
session[:short] = 1
render :nothing => true

def status
render :text => “session[:short] = #{session[:short]}”

This app is using the default Pstore sessions

I ran this app on a bunch of mongrels. In one browser window I kicked
off the long action, meanwhile in the second I ran the short action, and
then the status action to verify that the session did indeed contain the
value 1 for the key :short.

However once the long running action completes in then clobbers the hash
with its view of the world. session[:short] goes back to being empty.

Looking at the source it is clear why this happens: the first time the
session is accessed it is loaded from disk, and it is written back when
the action completes: it doesn’t care if the session has changed in

Obviously we don’t store anything vital in the session, but I was
wondering how other people cope with this.



In case anyone digs up this thread, I implemented a solution to this
problem here:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs