# Rails 2.3 deleting sessions

**URL:** <https://www.ruby-forum.com/t/rails-2-3-deleting-sessions/163350>\
**Category:** Rails\
**Created:** [March 19, 2009, 2:42pm UTC](https://www.ruby-forum.com/t/rails-2-3-deleting-sessions/163350 "2009-03-19T14:42:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ed8c4c/32.png) [@jay](https://www.ruby-forum.com/u/jay)\
**Post date:** [March 19, 2009, 2:42pm UTC](https://www.ruby-forum.com/t/rails-2-3-deleting-sessions/163350/1 "2009-03-19T14:42:22Z")

</div>

The following line no longer works in 2.3:

ActiveRecord::SessionStore.delete\_all [‘updated\_at \< ?’, 24.hours.ago]

Does anyone know how to do this in 2.3?

Thanks,  
Jay

---

<div class="post-metadata">

**Author:** ![jay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ed8c4c/32.png) [@jay](https://www.ruby-forum.com/u/jay)\
**Post date:** [March 19, 2009, 3:07pm UTC](https://www.ruby-forum.com/t/rails-2-3-deleting-sessions/163350/2 "2009-03-19T15:07:58Z")

</div>

Jay wrote:

> The following line no longer works in 2.3:
> 
> ActiveRecord::SessionStore.delete\_all [‘updated\_at \< ?’, 24.hours.ago]
> 
> Does anyone know how to do this in 2.3?

Do you really need to go though Rails to do this? I think I would just  
write a simple script and execute it in a cron task to clear out old  
sessions.

As far as I can tell, as long as the sessions fit the criteria for  
cookie based session stores, it seems to me like a very clean way to  
deal session data. That way the server and database are relieved from  
the burden of dealing with sessions.

I am also looking forward to the day when it becomes feasible to use  
HTML 5.0 local storage to keep session data. I believe this will be the  
final solution to dealing with persistent data for web applications. It  
eliminates the current limitations of cookie based sessions while  
simultaneously pushing state related information out to the client-side  
where, IMHO, it belongs.

---

<div class="post-metadata">

**Author:** ![jay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/ed8c4c/32.png) [@jay](https://www.ruby-forum.com/u/jay)\
**Post date:** [March 19, 2009, 3:51pm UTC](https://www.ruby-forum.com/t/rails-2-3-deleting-sessions/163350/3 "2009-03-19T15:51:12Z")

</div>

Ouch, you’re right !

I’ve the same problem, I watch the API and solved !

Try this:

ActiveRecord::SessionStore::Session.delete\_all [‘updated\_at \< ?’,  
24.hours.ago]

Have fun !
