Token::generate (method)

Return to Knowledgebase

Purpose

Generates a token and saves it to a session variable.

Location

users/classes/Token.php

See Also:

Token::check (method)

Parameters

This function does not take any arguments

Example

Token::generate

Further Documentation:

The token system is a type of two factor authentication system for forms. When a form is generated on screen a token is generated and stored in a session variable. It is then sent in via post with the rest of the form. Token::check makes sure those 2 tokens match. If they do not, it is assumed that some sort of manipulation happened with the form. Modern versions of UserSpice share one token per session so the Token::generate can be called multiple times without causing issues. Simply add a hidden form field for your token.