function language_cookie_set in Language Cookie 7
Same name and namespace in other branches
- 7.2 language_cookie.module \language_cookie_set()
Set cookie for current language. If no parameter is passed the current language is used.
Parameters
string $lang:
1 call to language_cookie_set()
- language_cookie_boot in ./
language_cookie.module - Implements hook_boot().
File
- ./
language_cookie.module, line 81 - Language Cookie module.
Code
function language_cookie_set($lang = NULL) {
if (!$lang) {
global $language;
$lang = $language->language;
}
$cookie = new stdClass();
$cookie->name = variable_get('language_cookie_param', 'language');
$cookie->value = $lang;
$cookie->expire = variable_get('language_cookie_time', 31536000);
$cookie->path = variable_get('language_cookie_path', '/');
$cookie->domain = variable_get('language_cookie_domain', '');
$cookie->secure = FALSE;
$cookie->httponly = FALSE;
// Allow other modules to alter the cookie. Include bootstrap modules
// only as this is being called during hook_boot().
// @see bootstrap_invoke_all()
foreach (module_list(FALSE, TRUE) as $module) {
drupal_load('module', $module);
// Note: this will be executed during hook_boot(), so be careful not
// to use module_implements() directly or indirectly during
// hook_language_cookie_alter().
module_invoke($module, 'language_cookie_alter', $cookie);
}
setrawcookie($cookie->name, rawurlencode($cookie->value), REQUEST_TIME + $cookie->expire, $cookie->path, $cookie->domain, $cookie->secure, $cookie->httponly);
}