function captcha_cron in CAPTCHA 8
Same name and namespace in other branches
- 6.2 captcha.module \captcha_cron()
- 7 captcha.module \captcha_cron()
Implements hook_cron().
Remove old entries from captcha_sessions table.
File
- ./
captcha.module, line 111 - This module enables basic CAPTCHA functionality.
Code
function captcha_cron() {
// Get request time.
$request_time = \Drupal::time()
->getRequestTime();
// Remove challenges older than PHP's session.gc_maxlifetime value.
$connection = Database::getConnection();
$connection
->delete('captcha_sessions')
->condition('timestamp', $request_time - ini_get('session.gc_maxlifetime'), '<')
->execute();
}