Back to CMSApplication class

Method getUserState

public mixed
getUserState
(mixed $key, mixed $default = null)
Gets a user state.
Parameters
  • string $key The path of the state.
  • mixed $default Optional default value, returned if the internal value is null.
Returns
  • mixed The user state or null.
Since
  • 3.2

Method getUserState - Source code

/**
 * Gets a user state.
 *
 * @param   string  $key      The path of the state.
 * @param   mixed   $default  Optional default value, returned if the internal value is null.
 *
 * @return  mixed  The user state or null.
 *
 * @since   3.2
 */
public function getUserState($key, $default = null)
{
    $registry = $this->getSession()->get('registry');
    if ($registry !== null) {
        return $registry->get($key, $default);
    }
    return $default;
}