delete stale sessions in ror web application

hi,

in my webapplication, user logins into application. i want to delete the
stale sessions. and while before deleting the stale session auomatically
i need perform on some operations on database. how to do this

Regards,
Rajkumar