Back to Session class

Method set

public mixed
set
(mixed $name, mixed $value = null)
Set data into the session store.
Parameters
  • string $name Name of a variable.
  • mixed $value Value of a variable.
Returns
  • mixed Old value of a variable.
Since
  • 1.5
Class: Session
Project: Joomla

Method set - Source code

/**
 * Set data into the session store.
 *
 * @param   string  $name   Name of a variable.
 * @param   mixed   $value  Value of a variable.
 *
 * @return  mixed  Old value of a variable.
 *
 * @since   1.5
 */
public function set($name, $value = null)
{
    // Handle B/C by checking if a namespace was passed to the method, will be removed at 5.0
    if (\func_num_args() > 2) {
        $args = \func_get_args();
        if (!empty($args[2])) {
            @trigger_error('Passing a namespace as a parameter to ' . __METHOD__ . '() is deprecated. ' . 'The namespace should be prepended to the name instead.', E_USER_DEPRECATED);
            $name = $args[2] . '.' . $name;
        }
    }
    return parent::set($name, $value);
}