Multiple database login issue

Here is a problem which is quite mysterious to me,

I am having multiple database architecture, each user logs in with
organisation name/user name/password
There is a master database and a table 'names' which contains the
names
of the database corresponding to each organisation name

I am using
ActiveRecord::Base.connection.execute('USE '+name_from
_master_db_table+'')

to dynamically switch the database, also i am using
act_as_authenticated
plugin to login the users

Now the issue is that i need to login twice to enter, also if i
login in
a different browser with a different org name(which connects to a
different db ) the page in the initial browser gets logged out, All
these used to work fine when the session store was cookie based , now
that i have changed to active_record store, I am facing these issues,
any idea or suggestion on this would be helpful a lot.

well when you switch the database like that you're probably leaving it
switched, so when the next request is handled it's trying to get the
session from the wrong database.

Fred

Frederick Cheung wrote:

Frederick Cheung wrote:

ActiveRecord::Base.connection.execute('USE '+name_from
these used to work fine when the session store was cookie based ,
now
that i have changed to active_record store, I am facing these
issues,
any idea or suggestion on this would be helpful a lot.

well when you switch the database like that you're probably leaving
it
switched, so when the next request is handled it's trying to get the
session from the wrong database.

Fred

Thanks fred, but I am storing the db info in the cookie and using a
before filter in the application.rb, so I guess its some issue with
act_as_auth plugin?

The fact that it worked fine when the session store was cookie based
makes that seem unlikely. Perhaps the before_filter from acts_as_auth
runs before your before_filter that sets the db.

Fred