MongoDbSessionHandler
class MongoDbSessionHandler implements SessionHandlerInterface
MongoDB session handler.
Methods
Constructor.
{@inheritdoc}
{@inheritdoc}
{@inheritdoc}
{@inheritdoc}
{@inheritdoc}
{@inheritdoc}
Details
at line line 70
__construct(Mongo|MongoClient $mongo, array $options)
Constructor.
List of available options: * database: The name of the database [required] * collection: The name of the collection [required] * idfield: The field name for storing the session id [default: _id] * datafield: The field name for storing the session data [default: data] * timefield: The field name for storing the timestamp [default: time] * expiryfield: The field name for storing the expiry-timestamp [default: expires_at]
It is strongly recommended to put an index on the expiry_field
for
garbage-collection. Alternatively it's possible to automatically expire
the sessions in the database as described below:
A TTL collections can be used on MongoDB 2.2+ to cleanup expired sessions automatically. Such an index can for example look like this:
db.<session-collection>.ensureIndex(
{ "<expiry-field>": 1 },
{ "expireAfterSeconds": 0 }
)
More details on: http://docs.mongodb.org/manual/tutorial/expire-data/
If you use such an index, you can drop gc_probability
to 0 since
no garbage-collection is required.
at line line 93
open($savePath, $sessionName)
{@inheritdoc}
at line line 101
close()
{@inheritdoc}
at line line 109
destroy($sessionId)
{@inheritdoc}
at line line 121
gc($maxlifetime)
{@inheritdoc}
at line line 133
write($sessionId, $data)
{@inheritdoc}
at line line 155
read($sessionId)
{@inheritdoc}