# How do we handle session timeout

**URL:** <https://www.ruby-forum.com/t/how-do-we-handle-session-timeout/131439>\
**Category:** Rails\
**Created:** [March 10, 2008, 3:48am UTC](https://www.ruby-forum.com/t/how-do-we-handle-session-timeout/131439 "2008-03-10T03:48:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![beginner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/e495f1/32.png) [@beginner](https://www.ruby-forum.com/u/beginner)\
**Post date:** [March 10, 2008, 3:48am UTC](https://www.ruby-forum.com/t/how-do-we-handle-session-timeout/131439/1 "2008-03-10T03:48:21Z")

</div>

Currently I am using ActiveRecord as session store. And have this  
(protect\_from\_forgery :secret=“xxxx”) set in ApplicationController. Also  
every five minutes I have a cron job to delete any session record that  
has not been updated for 15 minutes (by checking updated\_at column  
value).

The problem is: If I stay in one page and editing a long article, after  
20 minutes something, if I click on save. Server will throw This error:  
ActionController::InvalidAuthenticityToken  
(ActionController::InvalidAuthenticityToken).

Most likely that the session record is not updated while I am editing  
the article. And it gets removed by cron job.

I have two questions:

1. What triggers session record get updated in Rails?

2. How do I handle this scenario?

Thanks a lot for help.
