6

I am trying to set $cookie_domain in my settings.php within Drupal 8.

In Drupal 7, I add this in settings.php to set it up, but I am not sure how to do it in Drupal 8:

$cookie_domain = ".domain.com";

Thanks a lot

11

This is a container parameter now.

Put this in services.yml or another service definition YAML file:

parameters:
  session.storage.options:
    cookie_domain: '.domain.com'

Since it is in a yaml file, it can't easily be dynamic, one option you have is having multiple yml files, and you dynamically add the one for the right environment, or you have a services.local.yml, just like settings.local.php that you have on each environment and not in git.

  • 1
    You are right. I'm just adding that any additional YAML file can be loaded in the settings or local.settings files like this : $settings['container_yamls'][] = __DIR__ . '/ENV.services.yml'; – Renrhaf Apr 11 '17 at 5:15
  • 1
    Is it possible to set IP Address, Instead of domain? – AshwinP Dec 11 '17 at 14:34
  • 2
    @AshwinP There should be hostname what the browsers will see, so if your users access site by IP address it will work like this. But usually users use domain name. :-) – Bobík Jan 8 at 17:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.