SymfonyComponentHttpFoundationSessionStorageHandlerMongoDbSessionHandler

MongoDB session handler

Summary

No public properties found
No constants found
No protected methods found
No protected properties found
N/A
File
vendorSymfonyComponentHttpFoundationSessionStorageHandlerMongoDbSessionHandler.php
Package
Default
Class hierarchy
SymfonyComponentHttpFoundationSessionStorageHandlerMongoDbSessionHandler
Implements
SessionHandlerInterface

Tags

author

Markus Bachmann markus.bachmann@bachi.biz

Properties

$mongo

$mongo : \Mongo

Type

Mongo

Tags

None found

$collection

$collection : \MongoCollection

Type

MongoCollection

Tags

None found

$options

$options : array

Type

array

Tags

None found

Methods

__construct()

__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]
  • id_field: The field name for storing the session id [default: _id]
  • data_field: 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

Throws

InvalidArgumentException

When MongoClient or Mongo instance not provided

InvalidArgumentException

When "database" or "collection" not provided

Tags

None found

open()

open(string  $savePath, string  $sessionName) : boolean

Open session.

Parameters

string $savePath

Save path.

string $sessionName

Session Name.

Returns

boolean

Tags

None found

close()

close() : boolean

Close session.

Returns

boolean

Tags

None found

destroy()

destroy(string  $sessionId) : boolean

Destroys this session.

Parameters

string $sessionId

Session ID.

Returns

boolean

Tags

None found

gc()

gc(integer  $lifetime) : boolean

Garbage collection for storage.

Parameters

integer $lifetime

Max lifetime in seconds to keep sessions stored.

Returns

boolean

Tags

None found

write()

write(string  $sessionId, string  $data) : boolean

{@inheritDoc]

Parameters

string $sessionId

Session ID.

string $data

Session serialized data to save.

Returns

boolean

Tags

None found

read()

read(string  $sessionId) : string

Read session.

Parameters

string $sessionId

Returns

string —

String as stored in persistent storage or empty string in all other cases.

Tags

None found

getCollection()

getCollection() : \MongoCollection

Return a "MongoCollection" instance

Returns

MongoCollection

Tags

None found