Gossamer Forum
Home : General : Databases and SQL :

auto deletion of session-tracking rows in MySQL

Quote Reply
auto deletion of session-tracking rows in MySQL
Not sure if this is really a database question or a programming question... Basically, though, I'm going to be using a MySQL table for tracking user sessions. I know this is a very common technique, and it's simple enough to add the row when someone logs in, including an expiry time. But what's the best way to have rows automatically deleted when the session expires? Is that something that can be done on the database level, or do I just need to build a "trigger" into whatever script is using the database?

Thanks for any advice or suggestions.

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund
Quote Reply
Re: [hennagaijin] auto deletion of session-tracking rows in MySQL In reply to
Two suggestions:

1) In your login script, check the expire date/time against the current date/time and if the expire date/time has passed, delete all rows with the expire date that has passed.

2) Create an automated script that runs every ten minutes or hour and delete the rows based on the expire date/time.
========================================
Buh Bye!

Cheers,
Me
Quote Reply
Re: [Stealth] auto deletion of session-tracking rows in MySQL In reply to
Thanks - good ideas, both.

Fractured Atlas :: Liberate the Artist
Services: Healthcare, Fiscal Sponsorship, Marketing, Education, The Emerging Artists Fund