Topic: Performing actions based on session timeouts

Hi guys,

I'm writing a small Rails application which involves users uploading images. The images are only temporary but are saved on the server for the duration of their session. I have got it to log users out after 30 minutes of inactivity but I need to get it to delete their image that they uploaded from the disk.

Currently to log them out, it writes a new cookie with the current timestamp on it each time they load a page. When they try and access a page and the difference between the cookie variable and the current time in more than 30 minutes it logs them out immediately. The problem is that it requires them to visit the page to log them out again.

What I need is a way to perform the delete 30 minutes after they last access a page without the interaction of the user. This is mainly to save space on the server.

I'm kind of stuck and I was wondering if anyone had any ideas?

Thanks!