Symfony2 - PDO 会话 - 我需要手动删除记录还是一切都是自动的?

Symfony2 - PDO sessions - Do I need to delete records manually or is everything automatic?

我已经实现了 PDO 会话存储(= 会话现在保存在 mysql 数据库 table 中)。 这是 symfony2 参考:
http://symfony.com/doc/current/cookbook/configuration/pdo_session_storage.html

如果我访问我的网络应用程序的一个页面(即使没有登录),我的会话中会添加 2 条记录 table。这是正常的吗? (一个用户2条记录)
然后,如果我登录,那 2 条记录将被更改(但没有添加任何记录)。 最后,如果我注销,这2条记录又变了,但没有被删除。

如果现在一切都正确,how/when 过期会话的记录会从数据库中删除吗table?我需要执行 cronjob 还是 symfony 会自动执行?

那么,我是否需要做某事(= 编写一些特定代码)?

我发现了这个问题:
Symfony2, Configure pdo session storage in database
垃圾收集器是负责删除会话table中记录的那个吗?默认是激活的吗?

默认情况下应该是自动的,但过期的会话不会在每次请求时被删除,而是根据某种概率(默认为 1% 的概率)删除。

\Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler

public function gc($maxlifetime)
{
    // delete the session records that have expired
    $sql = "DELETE FROM $this->table WHERE $this->timeCol < :time";

    try {
        $stmt = $this->pdo->prepare($sql);
        $stmt->bindValue(':time', time() - $maxlifetime, \PDO::PARAM_INT);
        $stmt->execute();
    } catch (\PDOException $e) {
        throw new \RuntimeException(sprintf('PDOException was thrown when trying to delete expired sessions: %s', $e->getMessage()), 0, $e);
    }

    return true;
}

http://php.net/manual/en/sessionhandlerinterface.gc.php

您还可以为注销提供商设置 invalidate_session 密钥。它应该从数据库中销毁会话。

logout:
    invalidate_session: true