For example, the following two controller code samples are equivalent:
$key = $this->request->data['security']['token'];
if (!RequestToken::check($key)) {
Handle invalid request...
}
if (!RequestToken::check($this->request)) {
Handle invalid request...
}
public static check ( mixed $key, array $options = [] ) : boolean | ||
$key | mixed | Either the actual key as a string, or a `Request` object containing the key. |
$options | array | The options to use when matching the key to the token: - `'sessionKey'` _string_: The key used when reading the token from the session. |
return | boolean | Returns `true` if the hash key is a cryptographic match to the stored session token. Returns `false` on failure, which indicates a forged request attempt. |