The issue was solved by creating a special code that forcibly closes the session after the timer expires (a function that automatically starts in the plugin and forcibly checks sessions for the date of their expiration).
You need to download this file: https://drive.google.com/file/d/14LjYdKB0VtULmRjcE6S9lwmSBZTNxgQc/view?usp=sharing
and put it to:
/wp-content/plugins/sessions/includes/system/ (replace original class-session.php)
This is a code, that was added into original class-session.php (lines 1025 – 1064):
public static function try_to_terminate_sessions() {
global $wpdb;
$cpt = 0;
$limit = 0;
$index = 0;
$sql = 'SELECT user_id, meta_value FROM ' . $wpdb->usermeta . " WHERE meta_key='session_tokens' ORDER BY user_id DESC LIMIT " . (int) Option::network_get( 'buffer_limit' );
// phpcs:ignore
$query = $wpdb->get_results( $sql, ARRAY_A );
if ( is_array( $query ) && 0 < count( $query ) ) {
if ( $limit > count( $query ) ) {
$index = 0;
} else {
$index += $limit;
}
foreach ( $query as $row ) {
$sessions = $row['meta_value'];
if ( ! is_array( $sessions ) && is_string( $sessions ) ) {
$sessions = maybe_unserialize( $sessions );
}
if ( is_array( $sessions ) ) {
$cpt += Session::auto_terminate_session( $sessions, (int) $row['user_id'] );
}
}
switch ( $cpt ) {
case 0:
\DecaLog\Engine::eventsLogger( POSE_SLUG )->debug( 'No session to auto-terminate.' );
break;
case 1:
\DecaLog\Engine::eventsLogger( POSE_SLUG )->notice( sprintf( '%d session auto-terminated.', $cpt ) );
break;
default:
\DecaLog\Engine::eventsLogger( POSE_SLUG )->notice( sprintf( '%d sessions auto-terminated.', $cpt ) );
break;
}
} else {
\DecaLog\Engine::eventsLogger( POSE_SLUG )->debug( 'No session to auto-terminate.' );
$index = 0;
}
}
And call of the fuction (line 952 in modified class-session.php)
self::try_to_terminate_sessions();
Tested with sessions version 2.3.0
-
This reply was modified 3 years, 4 months ago by maycal.