You are here

CookieSameSiteSessionConfiguration.php in Media: Acquia DAM 8

File

src/Session/CookieSameSiteSessionConfiguration.php
View source
<?php

namespace Drupal\media_acquiadam\Session;

use Drupal\Core\Session\SessionConfiguration;
use Symfony\Component\HttpFoundation\Request;

/**
 * Defines the default session configuration generator.
 */
class CookieSameSiteSessionConfiguration extends SessionConfiguration {

  /**
   * {@inheritdoc}
   */
  public function getOptions(Request $request) {
    $options = parent::getOptions($request);

    // Return defaults if configuration tells us to disable the bypass.
    $config = \Drupal::configFactory()
      ->getEditable('media_acquiadam.settings');
    if ($config
      ->get('samesite_cookie_disable')) {
      return $options;
    }

    // Set the cookie samesite option to None.
    if (isset($options['cookie_secure']) && $options['cookie_secure'] == TRUE) {
      $options['cookie_samesite'] = 'None';
    }
    return $options;
  }

}

Classes

Namesort descending Description
CookieSameSiteSessionConfiguration Defines the default session configuration generator.