function MongoDbSessionHandler::doRead
Overrides AbstractSessionHandler::doRead
File
-
vendor/
symfony/ http-foundation/ Session/ Storage/ Handler/ MongoDbSessionHandler.php, line 161
Class
- MongoDbSessionHandler
- Session handler using the MongoDB driver extension.
Namespace
Symfony\Component\HttpFoundation\Session\Storage\HandlerCode
protected function doRead(string $sessionId) : string {
$cursor = $this->manager
->executeQuery($this->namespace, new Query([
$this->options['id_field'] => $sessionId,
$this->options['expiry_field'] => [
'$gte' => $this->getUTCDateTime(),
],
], [
'projection' => [
'_id' => false,
$this->options['data_field'] => true,
],
'limit' => 1,
]));
foreach ($cursor as $document) {
return (string) $document->{$this->options['data_field']} ?? '';
}
// Not found
return '';
}