Skip to content

Sessions garbage collector not used? #775

Open
@bezumkin

Description

@bezumkin

Hello!

I found a method modSessionHandler::gc(), that must delete old sessions, but it seems that it is never used.

I think, that is why my modx_session table takes 1gb and contains 500 000 records.

For me i wrote a simple script, that randomly deletes old sessions:

$rand = rand(1, 100);
if ($rand === 1) {
    $gcMaxlifetime = (integer) $modx->getOption('session_gc_maxlifetime', null, @ini_get('session.gc_maxlifetime'), true);
    $access = time() - $gcMaxlifetime;
    $modx->exec("
        DELETE FROM {$modx->getTableName('modSession')} WHERE `access` < {$access};
        OPTIMIZE TABLE {$modx->getTableName('modSession')};
    ");
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThe issue in the code or project, which should be addressed.needs-docsThe issue requires adding or updating documentation after the pull request merged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions