src/Middleware/LanguageSwitcherMiddleware.php
private function __setCookieAndLocale($locale)
    {
        // @FIXME Should be refactored when cake 3.4 was released
        if (PHP_SAPI !== 'cli') {
            $time = $this->__getCookieExpireTime();
            I18n::locale($locale);
            setcookie($this->__getCookieName(), $locale, $time, '/', $this->config('Cookie.domain'));
        }
    }
private function __setCookieAndLocale($locale)
    {
        // @FIXME Should be refactored when cake 3.4 was released
        if (PHP_SAPI !== 'cli') {
            $time = $this->__getCookieExpireTime();
            I18n::locale($locale);
            setcookie($this->__getCookieName(), $locale, $time, '/', $this->config('Cookie.domain'));
        }
    }
Set the cookie and the locale

@param string $locale locale
@return void