Back to CMSApplication class

Method setUserState

public mixed|void
setUserState
(mixed $key, mixed $value)
Sets the value of a user state variable.
Parameters
  • string $key The path of the state.
  • mixed $value The value of the variable.
Returns
  • mixed|void The previous state, if one existed.
Since
  • 3.2

Method setUserState - Source code

/**
 * 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);
    }
}