src/Web/Sessions/CachedSessionHandler.php
public function gc()
    {
        $promises = [];
        if (!$this->_gcIsRunning) {
            $this->_gcIsRunning = true;
            if (!empty($this->keys)) {
                $expiredTime = time() - $this->gcLifetime;
                foreach ($this->keys as $id => $ts) {
                    if ($ts > $expiredTime) {
                        continue;
                    }
                    $promise = $this->read($id)->then(
                        function($data) use ($id) {
                            return $this->archive->set($id, $data);
                        }
                    )->then(
                        function() use ($id) {
                            return $this->destroy($id, false);
                        }
                    )->otherwise(function() { return true; });
                    $promises[] = $promise;
                }
            }
            $promises[] = $this->archive->gc($this->gcArchiveLifetime);
        }
        if (!empty($promises)) {
            all($promises)->always(
                function() {
                    $this->_gcIsRunning = false;
                }
            );
        } else {
            $this->_gcIsRunning = false;
        }
    }
public function gc()
    {
        $promises = [];
        if (!$this->_gcIsRunning) {
            $this->_gcIsRunning = true;
            if (!empty($this->keys)) {
                $expiredTime = time() - $this->gcLifetime;
                foreach ($this->keys as $id => $ts) {
                    if ($ts > $expiredTime) {
                        continue;
                    }
                    $promise = $this->read($id)->then(
                        function($data) use ($id) {
                            return $this->archive->set($id, $data);
                        }
                    )->then(
                        function() use ($id) {
                            return $this->destroy($id, false);
                        }
                    )->otherwise(function() { return true; });
                    $promises[] = $promise;
                }
            }
            $promises[] = $this->archive->gc($this->gcArchiveLifetime);
        }
        if (!empty($promises)) {
            all($promises)->always(
                function() {
                    $this->_gcIsRunning = false;
                }
            );
        } else {
            $this->_gcIsRunning = false;
        }
    }
Cleanup old sessions. Timer callback.
Sessions that have not updated for the last '$this->gcLifetime' seconds will be archived.
Sessions in archive with age bigger than '$this->sessionLifetime' seconds will be removed.
@see $gcLifetime
@see $gcArchiveLifetime
@return void