On Oct 15, 2010, at 10:39 AM, Donald R. Ziesig wrote: > Hi Matt! > > My comments and questions are interspersed below. > > Thanks, > > Don > > On 10/14/2010 8:44 PM, Matt Jones wrote: >> 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) > > I tried this first, but the time-stamps did not change when the users > accessed the site. I was able to force a logout by deleting the appropriate > record, but had no way of determining when the timeout occurred.
You may need to grab the session's actual AR object and call 'touch' on it to update the updated_at column. > I have this working with a cron job that calls a method on the user update > controller. It can tell who has timed out, but has no way of forcing that > user to logout. > > My next idea is to try both. Something like: > > 1) use ajax in the browser to check for timeout - this works as long as the > user doesn't kill their browser without logging out. > > 2) use the active_record store to kill any records over (for example) 12 > hours old. > > The problem is that I have a requirement to audit the times the users are > logged in, but the web protocol can't tell me when the user just drops out. I'm not sure if that's entirely possible given the nature of the HTTP protocol, short of basically having the browser "ping" the server frequently. Otherwise, it's awfully hard to tell the difference between "user stared at the page for 2 hours" and "user navigated away from the page". --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.
