Hi all, I have set a session session to expire after an hour by doing: session[:expire] = { :expires => 1.hour.from_now } What I would like to do is have it so that session gets reset back an hour whenever a new page is loaded. If, however, the session variable has expired and the user tries to load a page I want my app to kick them back to a loggin page. I have tried to achieve this by saying: if !(session[:expire].blank? < 0.hour.from_now) session[:expire] = { :expires => 0.25.hour.from_now } end However, it doesn''t like the session[:expire]. It gives me: You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occurred while evaluating nil.[] even though I am saying if session is blank. Is there another way to do this. Thanks, -S -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Have a look at the sliding_session_timeout plugin: http://www.elctech.com/2007/10/29/sliding-session-timeout On Jun 28, 3:10 am, Shandy Nantz <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi all, > > I have set a session session to expire after an hour by doing: > session[:expire] = { :expires => 1.hour.from_now } > What I would like to do is have it so that session gets reset back an > hour whenever a new page is loaded. If, however, the session variable > has expired and the user tries to load a page I want my app to kick them > back to a loggin page. I have tried to achieve this by saying: > > if !(session[:expire].blank? < 0.hour.from_now) > session[:expire] = { :expires => 0.25.hour.from_now } > end > > However, it doesn''t like the session[:expire]. It gives me: > > You have a nil object when you didn''t expect it! > You might have expected an instance of Array. > The error occurred while evaluating nil.[] > > even though I am saying if session is blank. Is there another way to do > this. Thanks, > > -S > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Chris Bartlett wrote:> Have a look at the sliding_session_timeout plugin: > http://www.elctech.com/2007/10/29/sliding-session-timeout > > On Jun 28, 3:10�am, Shandy Nantz <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>session :session_expires => 10.minutes.from_now jst do this in ur application.rb and it will be applicable to ur whole application..It will work the same way u want.. no need to do necoding for it Hope this helps Thanks Dhaval Parikh Software Engineer Ruby on Rails http://www.railshouse.com sales(AT)railshouse(DOT)com -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---