# Do active\_record\_store sessions expire by default?

**URL:** <https://www.ruby-forum.com/t/do-active-record-store-sessions-expire-by-default/92298>\
**Category:** Rails\
**Created:** [April 18, 2007, 12:34am UTC](https://www.ruby-forum.com/t/do-active-record-store-sessions-expire-by-default/92298 "2007-04-18T00:34:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcampbell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8e7dd6/32.png) [@mcampbell](https://www.ruby-forum.com/u/mcampbell)\
**Post date:** [April 18, 2007, 12:34am UTC](https://www.ruby-forum.com/t/do-active-record-store-sessions-expire-by-default/92298/1 "2007-04-18T00:34:10Z")

</div>

If I’m not wrong, standard temp-file sessions expire when the active  
window closes, does the same go for active\_record\_store sessions or must  
they be emptied through specific instructions?

Thanks.

---

<div class="post-metadata">

**Author:** ![mcampbell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8e7dd6/32.png) [@mcampbell](https://www.ruby-forum.com/u/mcampbell)\
**Post date:** [April 18, 2007, 1:08am UTC](https://www.ruby-forum.com/t/do-active-record-store-sessions-expire-by-default/92298/2 "2007-04-18T01:08:44Z")

</div>

On Apr 18, 2007, at 12:34 AM, Peter Cho wrote:

> If I’m not wrong, standard temp-file sessions expire when the active  
> window closes, does the same go for active\_record\_store sessions or  
> must  
> they be emptied through specific instructions?

Session expiration equals session _cookie_ expiration.

By default the cookie has no expiration date, which means it expires  
when the user closes the browser. You can set a fixed expiration  
window with

ActionController::Base.session\_options[:session\_expires] = something

and dynamic expiration with this plugin

[http://agilewebdevelopment.com/plugins/dynamic\_session\_exp](http://agilewebdevelopment.com/plugins/dynamic_session_exp)

The very database cleanup has to be done by hand. Just put a cron  
task that deletes old records in the sessions table.

– fxn

---

<div class="post-metadata">

**Author:** ![mcampbell](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/8e7dd6/32.png) [@mcampbell](https://www.ruby-forum.com/u/mcampbell)\
**Post date:** [April 18, 2007, 3:39am UTC](https://www.ruby-forum.com/t/do-active-record-store-sessions-expire-by-default/92298/3 "2007-04-18T03:39:03Z")

</div>

Alright, thanks.
