Disable setting language cookie for curl or clients without user agents
This commit is contained in:
parent
8d7b270f6f
commit
6a7b8bd8fd
|
@ -428,6 +428,12 @@ final class MD_STD {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$lang = self::lang_getfrombrowser($allowed_langs, $default_lang, "", false);
|
$lang = self::lang_getfrombrowser($allowed_langs, $default_lang, "", false);
|
||||||
|
|
||||||
|
// If the user is a bot or has no user agent at all or one of curl's,
|
||||||
|
// setting a cookie usually makes little sense.
|
||||||
|
// On the other hand, setting the cookie prevents effective caching.
|
||||||
|
if (empty($_SERVER['HTTP_USER_AGENT']) || substr($_SERVER['HTTP_USER_AGENT'], 0, 5) === 'curl/') return $lang;
|
||||||
|
|
||||||
if (!setcookie('__Host-lang', $lang, $cookie_options)) {
|
if (!setcookie('__Host-lang', $lang, $cookie_options)) {
|
||||||
throw new Exception("Failed to set language");
|
throw new Exception("Failed to set language");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user