csrf_field
host callCapy
function csrf_field(session_name : string = "bearer-session", token_name : string = "csrf_token", field_name : string = "") string
Description
csrf_field() returns a hidden form input with the active CSRF token.
Use it in a form that changes state. Check the submitted value with csrf_valid() before you change state.
Parameters
session_name : the session and cookie name
token_name : the token namespace
fieldname : the form field name. The default is `tokenname`.
Return Values
An HTML hidden input with the active CSRF token.
Example
Capy
var field := csrf_field("capy-doc-session", "profile", "csrf_token")
print(contains(field, "type=\"hidden\""), "\n")