perooidically_call_remote

I am using the following for to peroidically call back to the control to see if a certain amount of time has passed:

in .rhtml <%= periodically_call_remote :url => { :action => 'session_expiry' }, :update => '' %>

in controller if !session[:expire].blank?    @time_left = (session[:expire][:expires] - Time.now).to_i else    @time_left = 0 end

if @time_left.to_i < 0 or @time_left == 0    flash[:notice] = "<b style = 'color: red;'>You have been logged out due      to inactivity</b>"    session[:user] = nil    redirect_to :action => 'login' end

The idea being that if too much time has passed the user gets signed out and get kicked back to the login page. Everything work right, except the bit of code that check to see if an hour has passed since the users last action and then it is supposed to redirect_to a login form. The problem is that when it gets to that redirect_to it seems to skip right over it and not do anything, even worse, it allows the user to continue to be logged in. Has anyone used peroidically_call_remote before and has similar issues and how did you fix them? Thanks,

-S

The idea being that if too much time has passed the user gets signed out and get kicked back to the login page. Everything work right, except the bit of code that check to see if an hour has passed since the users last action and then it is supposed to redirect_to a login form. The problem is that when it gets to that redirect_to it seems to skip right over it and not do anything, even worse, it allows the user to continue to be logged in. Has anyone used peroidically_call_remote before and has similar issues and how did you fix them? Thanks,

This has nothing to do with periodically_call_remote and everything to do with it being an ajax request. If you want to redirect from an ajax request you need to use rjs (ie remove the update option from periodically_call_remote) and use page.redirect_to from the rjs

Fred

Frederick Cheung wrote:

This has nothing to do with periodically_call_remote and everything to do with it being an ajax request. If you want to redirect from an ajax request you need to use rjs (ie remove the update option from periodically_call_remote) and use page.redirect_to from the rjs

Fred

That fixed it, thanks,

-S