/**
 * Sets the value of a user state variable.
 *
 * @param   string  $key    The path of the state.
 * @param   mixed   $value  The value of the variable.
 *
 * @return  mixed|void  The previous state, if one existed.
 *
 * @since   3.2
 */
public function setUserState($key, $value)
{
    $session = Factory::getSession();
    $registry = $session->get('registry');
    if ($registry !== null) {
        return $registry->set($key, $value);
    }
}