You are here

class MongodbSessionManager in MongoDB 8

Hierarchy

Expanded class hierarchy of MongodbSessionManager

1 string reference to 'MongodbSessionManager'
mongodb_user.services.yml in mongodb_user/mongodb_user.services.yml
mongodb_user/mongodb_user.services.yml
1 service uses MongodbSessionManager
mongodb.session_manager in mongodb_user/mongodb_user.services.yml
Drupal\mongodb_user\MongodbSessionManager

File

mongodb_user/src/MongodbSessionManager.php, line 18
Contains \Drupal\mongodb_user\MongodbSessionManager.

Namespace

Drupal\mongodb_user
View source
class MongodbSessionManager extends BaseSessionManager {

  /**
   * @var MongoCollectionFactory
   */
  protected $mongo;
  public function __construct(RequestStack $request_stack, MongoCollectionFactory $mongo, MetadataBag $metadata_bag, SessionConfigurationInterface $session_configuration, $handler = NULL) {
    BaseSessionManager::__construct($request_stack, new FakeConnection([]), $metadata_bag, $session_configuration, $handler);
    $this->mongo = $mongo;
  }
  public function delete($uid) {

    // Nothing to do if we are not allowed to change the session.
    if (!$this->writeSafeHandler
      ->isSessionWritable() || $this
      ->isCli()) {
      return;
    }
    $this->mongo
      ->get('sessions')
      ->remove(array(
      'uid' => (int) $uid,
    ));
  }
  protected function migrateStoredSession($old_session_id) {
    $criteria = [
      'sid' => Crypt::hashBase64($old_session_id),
    ];
    $newobj = array(
      'sid' => Crypt::hashBase64($this
        ->getId()),
    );
    $this->mongo
      ->get('sessions')
      ->update($criteria, $newobj);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DependencySerializationTrait::$_entityStorages protected property An array of entity type IDs keyed by the property name of their storages.
DependencySerializationTrait::$_serviceIds protected property An array of service IDs keyed by property name used for serialization.
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
MongodbSessionManager::$mongo protected property
MongodbSessionManager::delete public function Ends a specific user's session(s). Overrides SessionManager::delete
MongodbSessionManager::migrateStoredSession protected function Migrates the current session to a new session id. Overrides SessionManager::migrateStoredSession
MongodbSessionManager::__construct public function Constructs a new session manager instance. Overrides SessionManager::__construct
SessionManager::$connection protected property The database connection to use.
SessionManager::$requestStack protected property The request stack.
SessionManager::$sessionConfiguration protected property The session configuration.
SessionManager::$startedLazy protected property Whether a lazy session has been started.
SessionManager::$writeSafeHandler protected property The write safe session handler.
SessionManager::destroy public function Destroys the current session and removes session cookies. Overrides SessionManagerInterface::destroy
SessionManager::getSessionDataMask protected function Returns a map specifying which session key is containing user data.
SessionManager::isCli protected function Returns whether the current PHP process runs on CLI.
SessionManager::isSessionObsolete protected function Determines whether the session contains user data.
SessionManager::regenerate public function Regenerates id that represents this storage.
SessionManager::save public function Force the session to be saved and closed.
SessionManager::setWriteSafeHandler public function Sets the write safe session handler. Overrides SessionManagerInterface::setWriteSafeHandler
SessionManager::start public function Starts the session.
SessionManager::startNow protected function Forcibly start a PHP session.