symfony/symfony — pull request #12516 by bzikarsky (2014-11-19 13:18:31+00:00)
Title: MongoDbSessionHandler::read() now checks for valid session age

| Q | A
| ------------- | ---
| Bug fix? | yes/no
| New feature? | yes/no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | no
| Fixed tickets | -
| License | MIT
| Doc PR | -

This patch can be seen as either bugfix or feature, though it's probably more on the feature-side.

Currently a session will be returned by `read()` even if it's already older than `gc_maxlifetime`. If `gc_maxlifetime` is used for timing out sessions and a low gc-ratio is in place there is a high chance the session stays alive for a longer time than wanted. The manual describes the current limitations of `gc_maxlifetime` correctly at http://symfony.com/doc/current/components/http_foundation/session_configuration.html#session-lifetime.

But since the modification timestamp is stored in MongoDB anway, we can actually use it to only return "valid" session-data as does the [PdoSessionHandler](https://github.com/symfony/HttpFoundation/blob/2.7/Session/Storage/Handler/PdoSessionHandler.php#L518)