1 locale.inc locale_language_from_session($languages)

Identify language from a request/session parameter.


$languages: An array of valid language objects.

Return value

A valid language code on success, FALSE otherwise.:

Related topics


core/includes/locale.inc, line 233
Administration functions for locale.module.


function locale_language_from_session($languages) {
  $param = config_get('locale.settings', 'language_negotiation_session_parameter');

  // Request parameter: we need to update the session parameter only if we have
  // an authenticated user.
  if (isset($_GET[$param]) && isset($languages[$langcode = $_GET[$param]])) {
    global $user;
    if ($user->uid) {
      $_SESSION[$param] = $langcode;
    return $langcode;

  // Session parameter.
  if (isset($_SESSION[$param])) {
    return $_SESSION[$param];

  return FALSE;