$mongo
$mongo : \Mongo
MongoDB session handler.
__construct(\Mongo|\MongoClient $mongo, array $options)
Constructor.
List of available options:
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.
| \Mongo|\MongoClient | $mongo | A MongoClient or Mongo instance |
| array | $options | An associative array of field options |
When MongoClient or Mongo instance not provided
When "database" or "collection" not provided
open(string $savePath, string $sessionName) : boolean
Re-initializes existing session, or creates a new one.
| string | $savePath | Save path |
| string | $sessionName | Session name, see http://php.net/function.session-name.php |
true on success, false on failure
destroy(string $sessionId) : boolean
Destroys a session.
| string | $sessionId | Session ID, see http://php.net/function.session-id |
true on success, false on failure
write(string $sessionId, string $data) : boolean
Writes the session data to the storage.
Care, the session ID passed to write() can be different from the one previously received in read() when the session ID changed due to session_regenerate_id().
| string | $sessionId | Session ID , see http://php.net/function.session-id |
| string | $data | Serialized session data to save |
true on success, false on failure
read(string $sessionId) : string
Reads the session data.
| string | $sessionId | Session ID, see http://php.net/function.session-id |
Same session data as passed in write() or empty string when non-existent or on failure