PHP Class Contao\RequestToken

The class tries to read and validate the request token from the user session and creates a new token if there is none. Usage: echo RequestToken::get(); if (!RequestToken::validate('TOKEN')) { throw new Exception("Invalid request token"); }
Inheritance: extends System
显示文件 Open project: contao/core-bundle Class Usage Examples

Public Methods

Method Description
get ( ) : string Return the token
initialize ( ) Read the token from the session or generate a new one
validate ( string $strToken ) : boolean Validate a token

Method Details

get() public static method

Return the token
public static get ( ) : string
return string The request token

initialize() public static method

Read the token from the session or generate a new one
public static initialize ( )

validate() public static method

Validate a token
public static validate ( string $strToken ) : boolean
$strToken string The request token
return boolean True if the token matches the stored one