W3cubDocs

/Symfony 2.7

Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler

class MongoDbSessionHandler implements SessionHandlerInterface

MongoDB session handler

Methods

__construct(Mongo|MongoClient $mongo, array $options)

Constructor.

open($savePath, $sessionName)

{@inheritdoc}

close()

{@inheritdoc}

destroy($sessionId)

{@inheritdoc}

gc($maxlifetime)

{@inheritdoc}

write($sessionId, $data)

{@inheritdoc}

read($sessionId)

{@inheritdoc}

Details

public __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] * time_field: The field name for storing the timestamp [default: time]

Parameters

Mongo|MongoClient $mongo A MongoClient or Mongo instance
array $options An associative array of field options

Exceptions

InvalidArgumentException When MongoClient or Mongo instance not provided
InvalidArgumentException When "database" or "collection" not provided

public open($savePath, $sessionName)

{@inheritdoc}

Parameters

$savePath
$sessionName

public close()

{@inheritdoc}

public destroy($sessionId)

{@inheritdoc}

Parameters

$sessionId

public gc($maxlifetime)

{@inheritdoc}

Parameters

$maxlifetime

public write($sessionId, $data)

{@inheritdoc}

Parameters

$sessionId
$data

public read($sessionId)

{@inheritdoc}

Parameters

$sessionId