Skip to content

View Helpers

csrfMetaTags()

csrfMetaTags() — returns string

Available in: controller Category: Miscellaneous Functions

The csrfMetaTags() helper generates meta tags containing your application’s CSRF authenticity token. This is useful for JavaScript/AJAX requests that need to POST data securely, ensuring that the request comes from a trusted source.

<head>
    <title>My Application</title>
    #csrfMetaTags()#
</head>

// This will output something like:
// <meta name="csrf-token" content="YOUR_AUTH_TOKEN_HERE">
// <meta name="csrf-param" content="authenticityToken">