function language_from_session

Identify language from a request/session parameter.

Parameters

$languages: An array of valid language objects.

Return value

A valid language code on success, FALSE otherwise.

2 string references to 'language_from_session'
language_language_negotiation_info in drupal/core/modules/language/language.module
Implements hook_language_negotiation_info().
locale_update_8007 in drupal/core/modules/locale/locale.install
Convert language_negotiation_* variables to use the new callbacks.

File

drupal/core/modules/language/language.negotiation.inc, line 242
Language negotiation functions.

Code

function language_from_session($languages) {
  $param = config('language.negotiation')
    ->get('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;
}