You are here

public function MongodbSessionHandler::gc in MongoDB 8

Overrides SessionHandler::gc

File

mongodb_user/src/MongodbSessionHandler.php, line 155
Contains \Drupal\mongodb_user\MongodbSessionHandler.

Class

MongodbSessionHandler

Namespace

Drupal\mongodb_user

Code

public function gc($lifetime) {

  // Be sure to adjust 'php_value session.gc_maxlifetime' to a large enough
  // value. For example, if you want user sessions to stay in your database
  // for three weeks before deleting them, you need to set gc_maxlifetime
  // to '1814400'. At that value, only after a user doesn't log in after
  // three weeks (1814400 seconds) will his/her session be removed.
  $condition['timestamp']['$lt'] = REQUEST_TIME - $lifetime;
  $this
    ->mongoCollection()
    ->remove($condition);
  return TRUE;
}