function locale_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.

Related topics

1 string reference to 'locale_language_from_session'
locale_language_negotiation_info in modules/locale/locale.module
Implements hook_language_negotiation_info().

File

includes/locale.inc, line 234

Code

function locale_language_from_session($languages) {
    $param = variable_get('locale_language_negotiation_session_param', 'language');
    // 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;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.