-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[HttpFoundation] MongoDbSessionHandler supports auto expiry via configurable expiry_field #11510
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
bb336a5
796b18a
2d8b2bd
4d42f32
cb5e562
d748743
2f8742e
fc962db
b55c63b
88b256c
9744f61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,7 +110,7 @@ public function gc($maxlifetime) | |
* | ||
* See: http://docs.mongodb.org/manual/tutorial/expire-data/ | ||
*/ | ||
if ($this->options['expiry_field'] == false) { | ||
if ($this->options['expiry_field'] === false) { | ||
$time = new \MongoDate(time() - $maxlifetime); | ||
|
||
$this->getCollection()->remove(array( | ||
|
@@ -132,7 +132,7 @@ public function write($sessionId, $data) | |
$this->options['time_field'] => new \MongoDate(), | ||
); | ||
|
||
if ($this->options['expiry_field'] != false) { | ||
if ($this->options['expiry_field'] !== false) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
$expiry = new \MongoDate(time() + (int) ini_get('session.gc_maxlifetime')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Tobion: In #11508 (comment), you mentioned that the session lifetime option in Symfony sets the One concern I have is that we're storing the option's value from a particular point in time in this calculated value. If the PHP configuration changes because session lifetimes need to be extended site-wide, this storage layer is still going to delete those records based on the original time. I would assume other storage layers would simply delay their Just for context, ZF's MongoDB session handler stores the lifetime (i.e. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
But only for records that have not had activity, as they will have the new expireAt set based on whatever the maxlifetime may have been changed to. Not sure how much of an issue this actually is. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Good point! I missed that in my initial comment. No objection then, provided Symfony is OK with reading the |
||
$fields[$this->options['expiry_field']] = $expiry; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use Yoda expressions:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yes, will modify.