-
-
Save Sentinel-7/a645a0e3409e3f7df6b366821f7fadc0 to your computer and use it in GitHub Desktop.
Удаление старых сессий в таблице MODX посредством плагина, а не настройками PHP.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
на событие OnMODXInit | |
*/ | |
$rand = rand(1, 1000); | |
if ($rand === 1) { | |
$gcMaxlifetime = (integer) $modx->getOption('session_gc_maxlifetime', null, @ini_get('session.gc_maxlifetime'), true); | |
$access = time() - $gcMaxlifetime; | |
$modx->exec(" | |
DELETE FROM {$modx->getTableName('modSession')} WHERE `access` < {$access}; | |
OPTIMIZE TABLE {$modx->getTableName('modSession')}; | |
"); | |
$modx->log(modX::LOG_LEVEL_ERROR, 'clearOldSessions: old sessions have been removed.'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment