public function groupexSessionStart(GetResponseEvent $event) {
    $request = $event->getRequest();
    $uri = str_replace(base_path(), '/', $request->getRequestUri());
    if ($url_object = \Drupal::service('path.validator')->getUrlIfValid($uri)) {
      $route_name = $url_object->getRouteName();
      if ($route_name == 'openy_group_schedules.all_schedules_search' || $route_name == 'ymca_frontend.location_schedules') {
        $session = \Drupal::service('session_configuration');
        $options = $session->getOptions($request);
        if (isset($options['name']) && !$request->cookies->get($options['name'])) {
          $request->cookies->add([$options['name']]);
          session_set_cookie_params(0, $request->getRequestUri());
          session_start();
        }
      }
    }
  }
public function groupexSessionStart(GetResponseEvent $event) {
    $request = $event->getRequest();
    $uri = str_replace(base_path(), '/', $request->getRequestUri());
    if ($url_object = \Drupal::service('path.validator')->getUrlIfValid($uri)) {
      $route_name = $url_object->getRouteName();
      if ($route_name == 'openy_group_schedules.all_schedules_search' || $route_name == 'ymca_frontend.location_schedules') {
        $session = \Drupal::service('session_configuration');
        $options = $session->getOptions($request);
        if (isset($options['name']) && !$request->cookies->get($options['name'])) {
          $request->cookies->add([$options['name']]);
          session_set_cookie_params(0, $request->getRequestUri());
          session_start();
        }
      }
    }
  }
public function groupexSessionStart ( GetResponseEvent $ event ) { $ request = $ event -> getRequest ( ) ; $ uri = str_replace ( base_path ( ) , '/' , $ request -> getRequestUri ( ) ) ; if ( $ url_object = \ Drupal :: service ( 'path.validator' ) -> getUrlIfValid ( $ uri ) ) { $ route_name = $ url_object -> getRouteName ( ) ; if ( $ route_name == 'openy_group_schedules.all_schedules_search' || $ route_name == 'ymca_frontend.location_schedules' ) { $ session = \ Drupal :: service ( 'session_configuration' ) ; $ options = $ session -> getOptions ( $ request ) ; if ( isset ( $ options [ 'name' ] ) && ! $ request -> cookies -> get ( $ options [ 'name' ] ) ) { $ request -> cookies -> add ( [ $ options [ 'name' ] ] ) ; session_set_cookie_params ( 0 , $ request -> getRequestUri ( ) ) ; session_start ( ) ; } } } }
Disable Varnish and Page Cache.

We are dealing with Dynamic Page Cache and BigPipe plus lazy loaders.

@param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
Passed event.
Disable Varnish and Page Cache .