@param DataGrid         $dataGrid
@param SessionInterface $session

@throws \Exception

@return \Symfony\Component\HttpFoundation\RedirectResponse
336015
protected function redirectToExport(DataGrid $dataGrid, SessionInterface $session)
    {
        $filterConfig = $dataGrid->getQueryHandler();
        $selectedIds = [];
        if ($filterConfig instanceof DoctrineQueryHandlerInterface) {
            $alias = $filterConfig->getAlias();
            $qb = $filterConfig->getQueryBuilder();
            $qb->select($alias.'.id');

            $selectedIds = [];
            foreach ($qb->getQuery()->getArrayResult() as $result) {
                $selectedIds[] = $result['id'];
            }
        }

        $selectedColumns = [];
        foreach ($dataGrid->getColumns() as $column) {
            $selectedColumns[] = $column->getPropertyPath();
        }

        $configKey = uniqid('', false);
        $session->set('export_selected_ids_'.$configKey, $selectedIds);
        $session->set('export_selected_columns_'.$configKey, $selectedColumns);

        return $this->redirectToAction(
            'export',
            [
                'familyCode' => $this->family->getCode(),
                'configKey' => $configKey,
            ]
        );
    }
214433
public function pass(DataBagInterface $dataBag): DataBagInterface
    {
        $dataBag[$this->field] = ($this->callback)($dataBag[$this->field] ?? null, $dataBag);

        return $dataBag;
    }
663536
public function execute(RequestInterface $request): RequestInterface
    {
        if (is_null($this->sessionToken)) {
            return $request;
        } else {
            return $request->withHeader(
                self::HEADER_CLIENT_AUTHENTICATION,
                [$this->sessionToken->getToken()]
            );
        }
    }
15891
private function loadFromFile(SessionInterface $session)
    {
        $id = preg_replace('/[^\w\-]+/', '-', $session->getId());
        $dir = (new Config())->getSessionDir();
        $filename = "$dir/sess-$id/sess-$id.json";
        if (is_readable($filename) && ($contents = file_get_contents($filename))) {
            $data = json_decode($contents, true) ?: [];
            $session->setData($data);
            $this->save($session);
            // Reload the session from the keychain, and delete the file if
            // successful.
            if (rename($filename, $filename . '.bak')) {
                $this->load($session);
                if ($session->getData()) {
                    unlink($filename . '.bak');
                }
            }
        }
    }
407649
public function onSessionClose(Session $session)
    {
        if ($session->getRealm() && $session->getRealm()->getRealmName() === 'thruway.auth') {
            // session is closing in the auth domain
            // check and see if there are any registrations that came from this session
            $sessionId = $session->getSessionId();

            foreach ($this->authMethods as $methodName => $method) {
                if (isset($method['session_id']) && $method['session_id'] === $sessionId) {
                    unset($this->authMethods[$methodName]);
                }
            }
        }
    }
51074
protected function startSession($session)
    {
        if (is_bool($session) || is_string($session)) {
            if ($session === false || isset($_SESSION)) {
                return;
            }

            if (is_string($session)) {
                session_name($session);
            }

            return session_start();
        }

        $prefix = 'Session variable must be of type \'boolean\' or \'string\', \'';

        throw new \InvalidArgumentException($prefix . gettype($session) . '\' given.');
    }
9209
public function destroyRegisteredSsoClientSessions(SessionInterface $session) {
		if (!$session->isStarted()) {
			return;
		}

		$ssoClients = $this->getRegisteredSsoClients($session);
		$sessionId = $session->getId();

		$ssoServer = $this->ssoServerFactory->create();
		$this->ssoClientNotifier->destroySession($ssoServer, $sessionId, $ssoClients);
	}
1138515
public function deleteSessionAction($sessionId, Request $request)
    {
        /** @var $session \Symfony\Component\HttpFoundation\Session\Session */
        $session = $request->getSession();
        if (!$session->isStarted() || $session->getId() != $sessionId || !$this->hasStoredCsrfToken()) {
            $response = $this->authenticator->logout($request);
            $response->setStatusCode(404);

            return $response;
        }

        $this->checkCsrfToken($request);

        return new Values\DeletedUserSession($this->authenticator->logout($request));
    }
1148558
protected function storeCurrentUrl(Request $request, SessionInterface $session)
    {
        if ($request->getMethod() === 'GET') {
            $session->setPreviousUrl($request->fullUrl());
        }
    }
1028361
protected function getSessionId(Request $request, SessionInterface $session)
    {
        $name = $session->getName();

        return $request->cookies->get($name);
    }
1080388
protected function collectGarbage(SessionInterface $session)
    {
        $config = $this->getSessionConfig();

        if ($this->configHitsLottery($config)) {
            $lifetime = Arr::get($config, 'lifetime', 180);

            $session->getHandler()->gc($lifetime * 60);
        }
    }
685682
public function send(DispatcherResponseInterface $response)
    {
        if($response->isRedirect())
        {
            $session  = $response->getUser()->getSession();

            //Set the messages into the session
            $messages = $response->getMessages();
            if(count($messages))
            {
                //Auto start the session if it's not active.
                if(!$session->isActive()) {
                    $session->start();
                }

                $session->getContainer('message')->add($messages);
            }

            //Set the redirect into the response
            $format = $response->getRequest()->getFormat();
            if($format == 'json')
            {
                array_unshift($messages, sprintf('Redirecting to %1$s', $response->getHeaders()->get('Location')));

                $response->setContent(json_encode(array(
                    'messages' => $messages
                )), 'application/json');
            }

            if($format == 'html')
            {
                $response->setContent(sprintf(
                    '<!DOCTYPE html>
                        <html>
                            <head>
                                <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
                                <noscript>
                                    <meta http-equiv="refresh" content="1;url=%1$s" />
                                </noscript>
                                <title>Redirecting to %1$s</title>
                            </head>
                            <body onload="window.location = \'%1$s\'">
                                Redirecting to <a href="%1$s">%1$s</a>.
                            </body>
                        </html>'
                    , htmlspecialchars($response->getHeaders()->get('Location'), ENT_QUOTES, 'UTF-8')
                ), 'text/html');
            }

            return parent::send($response);
        }
    }
450156
public function startSession($sessionId = NULl){
        if($sessionId != NULL){ 
            session_id($sessionId);
        }
        session_start();
        $this->checkIdentity();
    }
514806
protected function saveFilters(SessionInterface $session, array $filters)
    {
        $this->saveValues($filters, $this->getFilterPrefix(), $session);
    }
577178
public static function createFromSymfonyGlobal(Session $session)
    {
        $baseRequest = BaseRequest::createFromGlobals();

        $query = $baseRequest->query->all();
        $request = $baseRequest->request->all();
        $attributes = array();
        $cookies = $baseRequest->cookies->all();
        $files = $baseRequest->files->all();
        $server = $baseRequest->server->all();
        $content = $baseRequest->getContent();

        $req = new static($query, $request, $attributes, $cookies, $files, $server, $content);
        $req->setSession($session);

        return $req;
    }
100880
private function downgrade(SessionInterface $session)
    {
        $queryManager = $session->getWorkspace()->getQueryManager();
        $localizations = $this->container->get('sulu_core.webspace.webspace_manager')->getAllLocalizations();

        $query = 'SELECT * FROM [nt:unstructured] WHERE ([jcr:mixinTypes] = "sulu:page" OR [jcr:mixinTypes] = "sulu:home")';
        $rows = $queryManager->createQuery($query, 'JCR-SQL2')->execute();

        /** @var Row $row */
        foreach ($rows as $row) {
            $node = $row->getNode();

            /** @var Localization $localization */
            foreach ($localizations as $localization) {
                $authoredPropertyName = sprintf('i18n:%s-authored', $localization->getLocale());
                if ($node->hasProperty($authoredPropertyName)) {
                    $node->getProperty($authoredPropertyName)->remove();
                }

                $authorPropertyName = sprintf('i18n:%s-author', $localization->getLocale());
                if ($node->hasProperty($authorPropertyName)) {
                    $node->getProperty($authoredPropertyName)->remove();
                }
            }
        }
    }
660965
public function setSessionStorage(SessionInterface $storage)
    {
        $storage->setServer($this);
        $this->sessionStorage = $storage;

        return $this;
    }