captcha_name

The 'captcha_name' directive sets the name of the cookie used to store the generated captcha value in the NGINX Captcha Module.

Syntaxcaptcha_name string;
DefaultCaptcha
Contexthttp, server, location
Arguments1

Description

The 'captcha_name' directive is a configuration option within the NGINX Captcha Module that specifies the name of the cookie that will hold the generated captcha value. This value is critical for validating the captcha to ensure that legitimate requests are processed while blocking automated submissions. By default, this cookie is named 'Captcha', but it can be customized to any string that meets the application requirements.

When a user attempts an action that requires a captcha, the server generates a captcha image based on the specified parameters (such as length and character set) and sends it to the user. The corresponding captcha value is hashed, and the generated hash is stored in a cookie with the name specified by the 'captcha_name' directive. During subsequent form submissions, this cookie can be referenced to validate that the user has solved the captcha correctly. The captcha validation logic checks against the cookie to ascertain if the correct captcha was inputted by the user.

This directive can be placed within various contexts, including 'http', 'server', and 'location', allowing for flexibility in its application. It's important to ensure that the cookie name is unique within the scope of your application to avoid conflicts with other cookies.

Config Example

location =/captcha {
    captcha;
    captcha_name CustomCaptchaName;
}

Ensure that the cookie name does not conflict with other cookies used in your application.

Changing the captcha name after users have started interacting can lead to validation issues as cookies may not sync properly.

← Back to all directives