src/Yggdrasil/Utils/Templating/FormExtension.php
public function generateCsrfToken(int $length = 32): string
    {
        $token = bin2hex(random_bytes($length));

        (new Session())->set('csrf_token', $token);

        return $token;
    }
public function generateCsrfToken(int $length = 32): string
    {
        $token = bin2hex(random_bytes($length));

        (new Session())->set('csrf_token', $token);

        return $token;
    }
public function generateCsrfToken ( int $ length = 32 ) : string { $ token = bin2hex ( random_bytes ( $ length ) ) ; ( new Session ( ) ) -> set ( 'csrf_token' , $ token ) ; return $ token ; }
Generates CSRF token

@param int $length Number of bytes to use to generate token
@return string
@throws \Exception
Generates CSRF token