getCsrfToken() public method

This token is generated in a way to prevent BREACH attacks. It may be passed along via a hidden field of an HTML form or an HTTP header value to support CSRF validation.
public getCsrfToken ( boolean $regenerate = false ) : string
$regenerate boolean whether to regenerate CSRF token. When this parameter is true, each time this method is called, a new CSRF token will be generated and persisted (in session or cookie).
return string the token used to perform CSRF validation.
Example #1
0
 public function testCsrfTokenValidation()
 {
     $this->mockWebApplication();
     $request = new Request();
     $request->enableCsrfCookie = false;
     $token = $request->getCsrfToken();
     $this->assertTrue($request->validateCsrfToken($token));
 }