Hello G.s,
I have an application which lets users login . In order to see how many
users are online (active in the last 20 mins) I have a before_filter on
every page which updates a column in the user table called
“last_hit_serverâ€
This is a little silly and is really slowing things down.
Here are my aims:
• I need to create a list of all the users active in the last 20 mins
• I need to be able to see when a user was ‘online’
Obviously I need to start tracking sessions, but I really need some help
with the logic of it
Here is what I’m thinking so far…
- When they log in I first check to see if there is a session already
assigned to that user- (If there is – I destroy it)
- I then create a new session and assign the user id to it.
“Who’s onlineâ€: I can then pull out a list of all the sessions which
have been updated in the past 20 mins along with the user id
When they log out, I destroy the session
But this doesn’t solve my problem of seeing when a person was last
‘online’ if I have destroyed the session
Any suggestions?