Auto-logout after 15 minutes

Hi There,

Im going through the ruby on rails tutorial ‘Railsspace’ at the
moment.

There is a :remember_me function that allows a cookie to be set at
login to remember the user. See below:

if @user.remember_me == “1”
cookies[:remember_me] = { :value => “cookie name”,
:expires => 2.minutes.from_now }
user.authorization_token = Digest::SHA1.hexdigest(
“#{user.username}:
#{user.password}”)

user.save!
cookies[:authorization_token] = {
:value => user.authorization_token,
:expires => 2.minutes.from_now }
else
cookies.delete(:remember_me)
cookies.delete(:authorization_token)

When i look in safari’s preferences, I can see that the cookie is set.
Agfter the 2 mins, I refresh the web page, and…

  • Safari removes the cookies, but the user still looks logged in.

Is there a way to amend this to ensure that say, after 15 mins, the
user is automatically logged out.

Can anyone help?

Many Thanks

Hi,

Use the “session-timeout” plugin.

http://github.com/lukeredpath/session-timeout/

Example:

session_times_out_in 15.minutes, :after_timeout => :do_something

Good luck.

Johalf Farina
+55 (51)8487 1402

Twitter http://twitter.com/johalf
Working with
Railshttp://www.workingwithrails.com/person/15914-johalf-farina
www.fande.com.br http://fande.com.br

On Tue, Oct 13, 2009 at 6:22 PM, RubyonRails_newbie <

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs