ActiveRecordStore: cleanup & avoiding duplication

Hi,

I’m using ActiveRecordStore to track user sessions.
I’ve used as a base the next sources:

This is what I currently do:

IN SESSION CONTROLLER

def create
self.current_user = User.authenticate(params[:login],
params[:password])
if logged_in?
session.model.user_id = current_user.id

if params[:remember_me] == "1"
  self.current_user.remember_me
end

current_user.update_attribute(:online, true)
redirect_back_or_default('/')

else
render :action => ‘new’
end
end

def destroy
self.current_user.forget_me if logged_in?
reset_session
current_user.update_attribute(:online, false)
redirect_back_or_default(‘/’)
end

FINDING SESSIONS

@online_sessions = CGI::Session::ActiveRecordStore::Session.find( :all,
:conditions => [ “updated_at > ? and user_id is not null”, Time.now() -
10.minutes ], :limit => 50 )


Everything loooks quite ok. I can login logout and I see how sessions
come and go. After 10 minutes the sessions are not shown as active.

MY QUESTIONS

1- How should I avoid duplicate sessions for users with an active
session? Where do I need to do the check? Any good example?

2- If I got it right I need to clean up the DB myself every now and
then. Is there anything else I need to clean up? Where is the stuff
stored at server? I’m using for development InstantRails in Windows but
I can’t find the created sessions anywhere.

Thanks again.