Tracking sessions

I posted on my blog about the session store I am currently using (the
one I was describing above). Most of my source code for the session
(if not all of it) is on display there.

http://burningtimes.net/articles/2006/10/15/paranoid-rails-session-storage

Erik

Erik wrote:

By doing that, you would have a list of active sessions, yes. However,
to find out which registered users were online (as opposed to anonymous
users), you would have to iterate the session records and check each
one for a user_id. On top of that, if you wanted to pull information
about each user that you found logged in (like user name, email
address, whatever you might have in the users table), you would have to
query the database again for each active session with a user_id–which
can quickly add up to a LOT of extra database hits and consequential
slow-down.

Erik

humm thats intresting Erik… something to consider when implementing a
real time contact list…

I am already updating a contact list of users every X secs to refresh if
they are on or off line. something like this is happening…

for user in current_user.orginaztion.users

#not sure yet how to express this in ruby code…
if user.id == current_session_id’s
user.online = true
else
user.offline = false
end
end

i suppose this would not ease the load any but its only happeing on one
page… that said my app really only has one main page that the user is
on :frowning:

Erik wrote:

I posted on my blog about the session store I am currently using (the
one I was describing above). Most of my source code for the session
(if not all of it) is on display there.

http://burningtimes.net/articles/2006/10/15/paranoid-rails-session-storage

Erik

Ctrl-D :wink:

Nobody has criticism to offer me?

Erik

Erik wrote the following on 16.10.2006 13:23 :

I posted on my blog about the session store I am currently using (the
one I was describing above). Most of my source code for the session
(if not all of it) is on display there.

http://burningtimes.net/articles/2006/10/15/paranoid-rails-session-storage

Nice documentation ! I’ve not read everything yet but this seems well
done.

Thanks,

Lionel