I am looking into creating a website similar to a chat program. I know when the user logs in. However, the user can log out any of the following ways: Logout link - This one is easy to handle User closer browser window User hits the back button User loses his/her internt connection. Is there a way within rails to handle the latter three user actions? Thanks! -- Posted via http://www.ruby-forum.com/.
Usually, the last three cases are handled with a timeout of some kind. If the user''s browser doesn''t interact with the server at all in a specific amount of time, then the server expires the session. Tim On Jul 25, 2006, at 10:07 AM, Chris Rericha wrote:> I am looking into creating a website similar to a chat program. I > know > when the user logs in. However, the user can log out any of the > following ways: > > Logout link - This one is easy to handle > User closer browser window > User hits the back button > User loses his/her internt connection. > > Is there a way within rails to handle the latter three user actions? > > Thanks! > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
How do I know when the session expires? In the case of a chat room, I would have to update the database or something so other people in the room see that that person is no longer in the room. Chris -- Posted via http://www.ruby-forum.com/.
You might want to use railscron to expire sessions that have not been updated in 20 minutes. - dan -- Dan Kohn <mailto:dan@dankohn.com> <http://www.dankohn.com/> <tel:+1-415-233-1000> On Jul 25, 2006, at 4:13 PM, Chris Rericha wrote:> How do I know when the session expires? In the case of a chat room, I > would have to update the database or something so other people in the > room see that that person is no longer in the room. > > Chris > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
A simple solution to expire sessions is to set expiry in controllers. E.g., class MyController session :session_expires => 2.minutes.from_now end While nice, this is not a great way to keep a "who''s online" list. It''s probably safest to keep an online status in the users table, and update it to Time.now each time a user browses to a new page. That way "who''s online" resolves to User.find(:conditions => [''last_hit_server_at'' > ?'', 2.minutes.ago]). -- View this message in context: http://www.nabble.com/Knowing-when-a-user-is-logged-in-tf2000253.html#a5498376 Sent from the RubyOnRails Users forum at Nabble.com.
Seemingly Similar Threads
- Session variable data validation
- [Bug 1185] New: counter flag proposal for sets and maps
- [Bug 1417] New: mapping to adjacent ranges is causing error in kernel 5.6, kernel 5.5 works fine
- [Bug 1127] New: running nft command creates lag for forwarded packets
- [Bug 1382] New: nftables.py cmd leaking memory when ruleset contain mapping ip length to range with high limit 65535