You are here

function hook_language_cookie_alter in Language Cookie 8

Modify the langage cookie that is set by this module.

Parameters

\Symfony\Component\HttpFoundation\Cookie &$cookie: The actual cookie, passed by reference.

See also

\Drupal\language_cookie\EventSubscriber\LanguageCookieSubscriber::setLanguageCookie()

1 invocation of hook_language_cookie_alter()
LanguageCookieSubscriber::setLanguageCookie in src/EventSubscriber/LanguageCookieSubscriber.php
Event callback for setting the language cookie.

File

./language_cookie.api.php, line 38
Documentation for Language Cookie module APIs.

Code

function hook_language_cookie_alter(Cookie &$cookie) {
  $default_langcode = \Drupal::languageManager()
    ->getCurrentLanguage()
    ->getId();
  $cookie = new Cookie('my_altered_language_cookie', $default_langcode);
}