Capy-Bearer Documentation

csrf_valid

host call

Capy

function csrf_valid(submitted : string, session_name : string = "bearer-session", token_name : string = "csrf_token") bool

Description

csrf_valid() checks a submitted CSRF token against the session token.

It does not create a missing token. Check the token before you apply a browser-submitted change.

Parameters

submitted : the value from the submitted form

session_name : the session and cookie name

token_name : the token namespace

Return Values

true if submitted matches the active session token.

Example

Capy

var token := csrf_token("capy-doc-session")
print(csrf_valid(token, "capy-doc-session"), "\n")