Skip to content

Instantly share code, notes, and snippets.

@marcelog
Created October 16, 2016 11:41
Show Gist options
  • Save marcelog/672cc10c1ba574adb3afb884e64d1337 to your computer and use it in GitHub Desktop.
Save marcelog/672cc10c1ba574adb3afb884e64d1337 to your computer and use it in GitHub Desktop.
Creating an event to remove sessions on expiration with MySQL events
CREATE EVENT `remove_sessions_production`
ON SCHEDULE EVERY 1 MINUTE
DO DELETE FROM `production_db`.`session` WHERE UNIX_TIMESTAMP(CURRENT_TIMESTAMP) - `last_activity` > 1800;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment