maintain_sessions.sql 358 B

12345678910
  1. CREATE PROCEDURE `maintain_sessions` () BEGIN
  2. DECLARE EXIT HANDLER FOR SQLEXCEPTION BEGIN
  3. ROLLBACK;
  4. GET DIAGNOSTICS CONDITION 1 @error = MESSAGE_TEXT;
  5. SET @error = CONCAT('Failed to maintain the sessions table. ',@error);
  6. RESIGNAL SET MESSAGE_TEXT = @error;
  7. END;
  8. DELETE FROM sessions
  9. WHERE date < TIMESTAMP(DATE_SUB(NOW(), INTERVAL 10 day));
  10. END;