Testing garbage collection

I’d like to force my server to consider my session variables as garbage after 1 minute. This is just a test to try to learn what’s really going on with the server and how it determines what garbage is. I have an issue with my application appearing to time out and I’m trying to replicate what I’m thinking the problem might be.

I’ve set up the php.ini file with these values:
session.gc_probability = 1
session.gc_divisor = 1 (trying to make the probability 100%)
session.gc_maxlifetime = 60

Previously, I had the default values set, and the issue would always occur after 24 minutes (session.gc_maxlifetime = 1440). With these changes made to php.ini, I’m not able to replicate the issue for the shorter time span. It is even possible to do so by playing with the php.ini file in this way? Is there something more going on with the server than just these settings?

You have done this correctly. But now remember that the session garbage collection is started when ‘someone’ visits your site. If you are the only one testing, like on your local PC, then your tests will not work as expected because you are deleting and then immediately resetting your own sessions.

What you need to do is to at least use 2 different browsers. Login from one browsers, then after 2 minutes or so visit your page from a different browsers. Then reload the page from browsers you logged in with. That’s the proper way to run your test.