Or a different approach using sessions stored in files After log-in, user will be added to a table - users online. In the front end of the application a autologoff js script set for 10 min. User will get a warning when no activity will be detected and then logged off. Then every 5 minutes a script run by crone could check the timestamp of all session files. If session timestamp > 10min then read user name from it and remove it from users online. If user was not logged in just delete the file. If user will press logoff remove from users online table.
On Mar 9, 3:42 pm, Jonathan Vanasco <[email protected]> wrote: > On Mar 9, 7:33 am, zepolen <[email protected]> wrote: > > > > > Add a 'last_action' datetime column to your user database, and do: > > > UPDATE users SET last_action = now() WHERE username = 'someuser' > > > on every nth request a (logged in) user does. > > > As for getting the current logged in users > > > SELECT username FROM users WHERE last_action > now() - interval '2 > > minute' > > > assuming you're using postgresql > > > You could add an index on last_action but that would slow down the > > UPDATE query which is done on every request for every user, so it's a > > better idea to not to add the index, and instead cache that second > > query for a minute or so in something like memcached. > > That's good for logging, but that would require hitting postgres on > EVERY page view... and would also have issues on a clustered system > ( where READ and WRITE dbs need to sync ). --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "pylons-discuss" 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/pylons-discuss?hl=en -~----------~----~----~----~------~----~------~--~---
