src/Controller/Component/ListFilterComponent.php
protected function _handlePersistedFilters()
    {
        if (isset($this->request->query['resetFilter'])) {
            $this->_controller->request->session()->delete($this->_getPersistendStorageKey('FormSession'));
            $this->Cookie->delete($this->_getPersistendStorageKey('FormCookie'));

            return $this->_controller->redirect($this->request->here);
        }
        $persistedFilterData = [];
        if ($this->config['FormSession']['active']) {
            $persistedFilterData = Hash::merge(
                $persistedFilterData,
                $this->_controller->request->session()->read($this->_getPersistendStorageKey('FormSession'))
            );
        }
        if ($this->config['FormCookie']['active']) {
            $persistedFilterData = Hash::merge(
                $persistedFilterData,
                $this->Cookie->read($this->_getPersistendStorageKey('FormCookie'))
            );
        }
        if (!empty($persistedFilterData)) {
            // Redirect the first time, $persistedFilterData is present (Filterredirect param not set)
            if (empty($this->_controller->request->query['Filterredirect'])) {
                if (!empty($persistedFilterData['Pagination']['page'])) {
                    $this->_controller->passedArgs['page'] = $persistedFilterData['Pagination']['page'];
                }
                if (!empty($persistedFilterData['Pagination']['sort'])) {
                    $this->_controller->passedArgs['sort'] = $persistedFilterData['Pagination']['sort'];
                }
                if (!empty($persistedFilterData['Pagination']['direction'])) {
                    $this->_controller->passedArgs['direction'] = $persistedFilterData['Pagination']['direction'];
                }
                unset($persistedFilterData['Pagination']);
                $redirectUrl = $this->getRedirectUrlFromPostData(['Filter' => $persistedFilterData]);
                $redirectUrl['Filterredirect'] = 1;
                // Redirect
                return $this->_controller->redirect($redirectUrl);
            }
            // Reset Session, if no Filter is set

            if (!$this->filterUrlParameterStatus()) {
                unset($persistedFilterData);
                $this->_controller->request->session()->delete($this->_getPersistendStorageKey('FormSession'));
                $this->Cookie->delete($this->_getPersistendStorageKey('FormCookie'));
            }

            $persistedFilterData['Pagination'] = [];
            if (!empty($this->_controller->request->query['page'])) {
                $persistedFilterData['Pagination']['page'] = $this->_controller->request->query['page'];
            }
            if (!empty($this->_controller->request->query['sort'])) {
                $persistedFilterData['Pagination']['sort'] = $this->_controller->request->query['sort'];
            }
            if (!empty($this->_controller->request->query['direction'])) {
                $persistedFilterData['Pagination']['direction'] = $this->_controller->request->query['direction'];
            }
            $this->_controller->request->session()->write(
                $this->_getPersistendStorageKey('FormSession'),
                $persistedFilterData
            );
            $this->Cookie->write($this->_getPersistendStorageKey('FormCookie'), $persistedFilterData);
        }
    }
protected function _handlePersistedFilters()
    {
        if (isset($this->request->query['resetFilter'])) {
            $this->_controller->request->session()->delete($this->_getPersistendStorageKey('FormSession'));
            $this->Cookie->delete($this->_getPersistendStorageKey('FormCookie'));

            return $this->_controller->redirect($this->request->here);
        }
        $persistedFilterData = [];
        if ($this->config['FormSession']['active']) {
            $persistedFilterData = Hash::merge(
                $persistedFilterData,
                $this->_controller->request->session()->read($this->_getPersistendStorageKey('FormSession'))
            );
        }
        if ($this->config['FormCookie']['active']) {
            $persistedFilterData = Hash::merge(
                $persistedFilterData,
                $this->Cookie->read($this->_getPersistendStorageKey('FormCookie'))
            );
        }
        if (!empty($persistedFilterData)) {
            // Redirect the first time, $persistedFilterData is present (Filterredirect param not set)
            if (empty($this->_controller->request->query['Filterredirect'])) {
                if (!empty($persistedFilterData['Pagination']['page'])) {
                    $this->_controller->passedArgs['page'] = $persistedFilterData['Pagination']['page'];
                }
                if (!empty($persistedFilterData['Pagination']['sort'])) {
                    $this->_controller->passedArgs['sort'] = $persistedFilterData['Pagination']['sort'];
                }
                if (!empty($persistedFilterData['Pagination']['direction'])) {
                    $this->_controller->passedArgs['direction'] = $persistedFilterData['Pagination']['direction'];
                }
                unset($persistedFilterData['Pagination']);
                $redirectUrl = $this->getRedirectUrlFromPostData(['Filter' => $persistedFilterData]);
                $redirectUrl['Filterredirect'] = 1;
                // Redirect
                return $this->_controller->redirect($redirectUrl);
            }
            // Reset Session, if no Filter is set

            if (!$this->filterUrlParameterStatus()) {
                unset($persistedFilterData);
                $this->_controller->request->session()->delete($this->_getPersistendStorageKey('FormSession'));
                $this->Cookie->delete($this->_getPersistendStorageKey('FormCookie'));
            }

            $persistedFilterData['Pagination'] = [];
            if (!empty($this->_controller->request->query['page'])) {
                $persistedFilterData['Pagination']['page'] = $this->_controller->request->query['page'];
            }
            if (!empty($this->_controller->request->query['sort'])) {
                $persistedFilterData['Pagination']['sort'] = $this->_controller->request->query['sort'];
            }
            if (!empty($this->_controller->request->query['direction'])) {
                $persistedFilterData['Pagination']['direction'] = $this->_controller->request->query['direction'];
            }
            $this->_controller->request->session()->write(
                $this->_getPersistendStorageKey('FormSession'),
                $persistedFilterData
            );
            $this->Cookie->write($this->_getPersistendStorageKey('FormCookie'), $persistedFilterData);
        }
    }
Handles filters which were persisted through cookies and / or the session.

@return mixed