Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[HttpFoundation] MongoDbSessionHandler does not support disabling of gc operations #11508

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

Closed
catchamonkey opened this issue Jul 29, 2014 · 8 comments

Comments

@catchamonkey
Copy link
Contributor

Hi,

I've implemented the MongoDbSessionHandler, am also using a Mongo index with expireAfterSeconds to expire the session after a set amount of inactivity.
However even with this set, the gc method still performs a delete operation of it's own.

Have thought about adding an option to the Session Handler to disable that method from doing anything, and also having the write method add the expires index.

Does that sound OK? Happy to code it and send a PR.
Thanks.

@Tobion
Copy link
Contributor

Tobion commented Jul 29, 2014

Yes I think it makes sense. But I would prefer http://docs.mongodb.org/manual/tutorial/expire-data/#expire-documents-at-a-certain-clock-time to be able to use different expire times per session. Also remember, that you can already disable gc via php by setting the probability to zero. So actually this is already possible.

@catchamonkey
Copy link
Contributor Author

Thanks @Tobion , good point about gc probability.

How would you see using the clock time expiry work here with an app level configured session handler?
How would you want to pass the expiry time to the handler so it can be different between writes?

@catchamonkey
Copy link
Contributor Author

Also, as the time field is the last updated time, (which we don't want to lose), using the clock time expiry would need an additional property being added for an expires at time.

@Tobion
Copy link
Contributor

Tobion commented Jul 29, 2014

In write you can do ini_get('session.gc_maxlifetime') which is used to define the maxlifetime.
See https://github.com/symfony/symfony/pull/10931/files#diff-5b96aee9c7c07a0e18d1fd32f7a3028eR318

@catchamonkey
Copy link
Contributor Author

Won't that be a BC break? As expiry would be moving from a configuration option of the framework/component, to a php.ini option?
Or is it OK if that is behind a new flag that maintains BC as default?

@Tobion
Copy link
Contributor

Tobion commented Jul 29, 2014

You can add an option to the handler. When active we use mongo ttl with expireAt field. When not active we use php gc and just the update time field (as now).

@catchamonkey
Copy link
Contributor Author

OK thanks, will work on that.

@Tobion
Copy link
Contributor

Tobion commented Jul 29, 2014

The framework config option is just a wrapper around ini_set AFAIK. And people can still manually call ini_set whenever they want (e.g. different per session).

nicolas-grekas added a commit that referenced this issue Aug 13, 2014
…xpiry via configurable expiry_field (catchamonkey)

This PR was squashed before being merged into the 2.3 branch (closes #11510).

Discussion
----------

[HttpFoundation] MongoDbSessionHandler supports auto expiry via configurable expiry_field

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

ToDo

 * [x] Fix Tests

Looking for feedback on this early PR.

This adds a config option that disables the PHP GC method call from doing anything,
It also means that the write method sets up the auto expiring index.

Ref: #11508

Commits
-------

b56b740 [HttpFoundation] MongoDbSessionHandler supports auto expiry via configurable expiry_field
nicolas-grekas added a commit that referenced this issue Aug 18, 2014
…xpiry via configurable expiry_field (catchamonkey)

This PR was merged into the 2.6-dev branch.

Discussion
----------

[HttpFoundation] MongoDbSessionHandler supports auto expiry via configurable expiry_field

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

This PR applies #11510 to master instead of 2.3

Should be merged on master:
- [x] after #11667 is merged to 2.3
- [x] and after 2.3 is merged back to master

Commits
-------

beca900 [HttpFoundation] MongoDbSessionHandler supports auto expiry via configurable expiry_field
@Tobion Tobion closed this as completed Oct 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants