Back to Form class

Method token

public static string
token
(array $attribs = array())
Displays a hidden token field to reduce the risk of CSRF exploits
Parameters
  • array $attribs Input element attributes.
Returns
  • string A hidden input field with a token
Since
  • 1.5
-
  • \Joomla\CMS\Session\Session::checkToken()
Class: Form
Project: Joomla

Method token - Source code

/**
 * Displays a hidden token field to reduce the risk of CSRF exploits
 *
 * Use in conjunction with Session::checkToken()
 *
 * @param   array  $attribs  Input element attributes.
 *
 * @return  string  A hidden input field with a token
 *
 * @see     Session::checkToken()
 * @since   1.5
 */
public static function token(array $attribs = array())
{
    $attributes = '';
    if ($attribs !== array()) {
        $attributes .= ' ' . ArrayHelper::toString($attribs);
    }
    return '<input type="hidden" name="' . Session::getFormToken() . '" value="1"' . $attributes . '>';
}