Hi, I am using sessions in my application and file store for sessions storage. now i want to expire my session after some short of idle time.for that i need the start time of the session. Does Any one know how can i get start time of the session ?? Thanks in Advance. Piyush. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Restful authentication / acts_as_authenticated does this by using a database field and setting a cookie. Perhaps you could take a look at the source code of that. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks for your response Ryan.. I found one another and easy way for doing same without getting start time for sessions. For doing session timeout after some idle time we can go with below thing. 1) Define below filter and methods in application.rb file. before_filter :update_activity_time, :except => :session_expiry def update_activity_time session[:expires_at] = 10.minutes.from_now end def session_expiry @time_left = (session[:expires_at] - Time.now).to_i unless @time_left > 0 reset_session render update do |page| page.redirect_to path for login page end end 2) Add below remote periodic call to the layout. <%= periodically_call_remote :url => { :action => '' session_expiry'' }, :update => '' '' %> Thats Done !! On Jul 9, 3:00 pm, Ryan Bigg <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Restful authentication / acts_as_authenticated does this by using a > database field and setting a cookie. Perhaps you could take a look at > th source code of that.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
In case it matters, periodically_call_remote *requires* javascript... so if a user disables JS, your example doesn''t work unless you do that expiry check before every request as well. On Wed, Jul 9, 2008 at 9:16 AM, Piyush with Rails <p.gajjariya-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Thanks for your response Ryan.. I found one another and easy way for > doing same without getting start time for sessions. > > For doing session timeout after some idle time we can go with below > thing. > > 1) Define below filter and methods in application.rb file. > > before_filter :update_activity_time, :except => :session_expiry > > def update_activity_time > session[:expires_at] = 10.minutes.from_now > end > > def session_expiry > @time_left = (session[:expires_at] - Time.now).to_i > unless @time_left > 0 > reset_session > render update do |page| > page.redirect_to path for login page > end > end > > 2) Add below remote periodic call to the layout. > > <%= periodically_call_remote :url => { > :action => '' session_expiry'' }, > :update => '' '' %> > > Thats Done !! > > > On Jul 9, 3:00 pm, Ryan Bigg <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > Restful authentication / acts_as_authenticated does this by using a > > database field and setting a cookie. Perhaps you could take a look at > > th source code of that. > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---