src/Viserio/Component/Session/Middleware/StartSessionMiddleware.php
protected function collectGarbage(StoreContract $session): void
    {
        $lottery     = $this->cookieConfig['lottery'];
        $hitsLottery = \random_int(1, $lottery[1]) <= $lottery[0];

        // Here we will see if this request hits the garbage collection lottery by hitting
        // the odds needed to perform garbage collection on any given request. If we do
        // hit it, we'll call this handler to let it delete all the expired sessions.
        if ($hitsLottery) {
            $session->getHandler()->gc($this->lifetime);
        }
    }
protected function collectGarbage(StoreContract $session): void
    {
        $lottery     = $this->cookieConfig['lottery'];
        $hitsLottery = \random_int(1, $lottery[1]) <= $lottery[0];

        // Here we will see if this request hits the garbage collection lottery by hitting
        // the odds needed to perform garbage collection on any given request. If we do
        // hit it, we'll call this handler to let it delete all the expired sessions.
        if ($hitsLottery) {
            $session->getHandler()->gc($this->lifetime);
        }
    }
Remove the garbage from the session if necessary.

@param \Viserio\Component\Contract\Session\Store $session

@return void