Support » Plugin: WP Session Manager » Understanding Garbage Collection

  • Resolved awfulclever


    Hello – I’m currently testing the plugin (v3.0.3) and had some questions about garbage collection. As I understand it, sessions should be deleted based on my php.ini settings. My current settings are the default php7.x settings which include:

    session.gc_maxlifetime = 1440
    session.cache_expire = 180

    In looking at the wp_sm_sessions table it appears that none of the sessions are being deleted, even after 6+ hours and subsequent visits to the site which successfully create new sessions and records in the database.

    The behavior I was expecting would be that records in the database older than 180 minutes would be deleted.

    Am I understanding this correctly? Or is there something else that needs to be done to enable garbage collection.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Eric Mann


    Garbage collection of sessions in PHP is somewhat random. It’s managed by two other INI settings: session.gc_divisor (default 100) and session.gc_probability (default 1).


    There is a session.gc_probability / session.gc_divisor chance that garbage collection will run on any given request. By default, that means only a 1% chance of garbage collection running.

    Why this isn’t more deterministic is beyond me, but I’m sure there’s a reason PHP is built that way.

    Thanks for the reply and explanation! This is very helpful. In subsequent monitoring I’ve confirmed garbage collection is occurring – Now the frequency and timing make sense.

    Great plugin! Thanks for your help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Understanding Garbage Collection’ is closed to new replies.