On Oct 14, 2010, at 8:28 PM, Donald R. Ziesig wrote:
> Hi All!
>
> I need to be able to force a user to logout if the session has been idle for
> a set time. (A typical pattern).
>
> I have gotten everything working excepting being able to cause a user,
> identified by the user.id field, to be logged out. That is, I create a db
> record when the user logs in, and update that record every time the user
> accesses the site. A cron job uses curl to interrogate the table of
> user_timeouts, with no problem finding the idle users and the value of their
> user.id. After that I can't seem to find the appropriate methods to force
> the logout.
>
> Help anyone?
There's not really a "Hobo-specific" way to do this; the standard method would
be to switch to the ActiveRecord session store and have a cron job periodically
sweep out old records. (then you wouldn't need the UserTimeout model)
Alternatively, you could try using a before_filter on your
ApplicationController that checks for the a "last accessed" time in the session
and either boots the user or updates that time. You'd need to hook into the
login method on your user controller:
def login
hobo_login do
session[:last_accessed] = Time.now
end
end
The first method has the advantage that it's possible to scan the sessions
table to see *who* is logged in, whereas the second method can't exactly poke
around in the cookies on the remote machines...
--Matt Jones
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/hobousers?hl=en.