Duplicate orders? Not anymore. WooCommerce protection is now included!
Upgrade to PRO for Checkout Blocks, analytics and smart order linking.

Duplicate Killer Cookie Architecture for Preventing Duplicate Submissions in WordPress

Duplicate Killer WordPress plugin preventing duplicate form submissions

This document provides a deep technical explanation of how the Duplicate Killer WordPress plugin implements cookie-based logic to assist with duplicate form submission prevention.

It is written for developers, agencies, and advanced WordPress users who want to understand exactly how the system behaves at runtime.


Problem Statement: Duplicate Submissions in WordPress

WordPress form plugins do not enforce uniqueness constraints. The same browser can submit identical values multiple times, intentionally or accidentally.

Duplicate Killer addresses this problem using a multi-layered strategy:

  • Server-side database duplicate checks
  • Optional client-side cookies (PRO only)
  • Per-field, per-form, per-plugin scoping

The cookie system is not a security feature. It is a context signal.


Cookie Design Philosophy

The cookie system follows these strict rules:

  • No personal data
  • No cross-form leakage
  • No global tracking
  • No assumptions about user identity

Each cookie answers only one question:

“Has this browser already submitted this exact form?”


Cookie Naming Convention (Critical for Isolation)

Cookies are generated using a deterministic naming scheme:

dk_form_cookie_{provider}_{form_id}

Examples:


dk_form_cookie_cf7_72
dk_form_cookie_elementor_forms_1fc7fb0
dk_form_cookie_forminator_92
dk_form_cookie_wpforms_96
dk_form_cookie_formidable_contact-us_2

This guarantees:

  • One cookie per form
  • One cookie per plugin
  • No collisions between providers

Frontend Cookie Creation Flow (JavaScript)

Duplicate Killer injects a single external JavaScript file. No inline scripts are used (CSP-safe).

High-Level Flow


DOM Ready
  ↓
Scan for supported form selectors
  ↓
Extract provider-specific form identifier
  ↓
Check allowlist (PRO configuration)
  ↓
Set cookie if allowed

Key JavaScript Logic (Simplified)


function setCookie(name, days) {
    if (document.cookie.includes(name + '=')) return;

    const token = Date.now().toString(36) + Math.random().toString(36).slice(2);
    const expires = new Date(Date.now() + days * 86400000).toUTCString();

    document.cookie =
        name + '=' + encodeURIComponent(token) +
        '; expires=' + expires +
        '; path=/; SameSite=Lax';
}

Important details:

  • The value is a random token (not meaningful)
  • The cookie is first-party
  • No HttpOnly flag (JS must read it)

Provider-Specific Form Identification

Each WordPress form plugin exposes form identifiers differently. Duplicate Killer handles this explicitly.

Contact Form 7


var cf7 = formEl.querySelector('input[name="_wpcf7"]');
return cf7 ? parseInt(cf7.value, 10) : null;

Elementor Forms


var ef = formEl.querySelector('input[name="form_id"]');
return ef ? ef.value.toLowerCase() : null;

Formidable Forms


var hidden = formEl.querySelector('input[name="form_id"]');
return hidden ? hidden.value.toLowerCase() : null;

Notice:

  • Numeric IDs are not assumed
  • String IDs are normalized and sanitized

PRO Allowlist: Why Cookies Are Not Global

Cookies are created only if the form is explicitly enabled in the database.

PHP Configuration Structure (Example)


$providers['cf7'] = [
    'enabled'       => true,
    'cookie_prefix' => 'dk_form_cookie_cf7_',
    'per_form_days' => [
        72 => 7,
        71 => 3,
    ],
];

If a form ID is missing from per_form_days, no cookie is created.

This prevents:

  • Accidental cookie creation
  • Unexpected behavior on unrelated forms

Backend Cookie Consumption (PHP)

Cookies are read during validation and save hooks.

Example: Cookie Reader Function


function dk_get_form_cookie_simple(array $options, string $form_name, string $cookie_prefix): array {

    $form_cookie = 'NULL';
    $checked_cookie = false;

    if (!isset($options[$form_name]['cookie_option']) ||
        $options[$form_name]['cookie_option'] !== '1') {
        return compact('form_cookie', 'checked_cookie');
    }

    $form_id = (string) $options[$form_name]['form_id'];
    $cookie_name = $cookie_prefix . sanitize_key($form_id);

    if (!empty($_COOKIE[$cookie_name])) {
        $form_cookie = sanitize_text_field(wp_unslash($_COOKIE[$cookie_name]));
        $checked_cookie = true;
    }

    return compact('form_cookie', 'checked_cookie');
}

This ensures:

  • Exact form matching
  • No false positives
  • Safe sanitization

How Cookies Interact With Duplicate Detection

The cookie value is passed into database checks:


duplicateKiller_check_duplicate_by_key_value(
    'elementor',
    $form_name,
    $field_key,
    $submitted_value,
    $form_cookie,
    $checked_cookie
);

The database layer can then decide:

  • Same value + same cookie → duplicate
  • Same value + different cookie → contextual decision

What the Cookie System Explicitly Does NOT Do

  • ❌ It does not replace database validation
  • ❌ It does not block submissions by itself
  • ❌ It does not track users across the site
  • ❌ It does not identify real people

Deleting cookies does not disable Duplicate Killer.


FREE vs PRO: Architectural Differences

FREE

  • No per-form cookie allowlist
  • No per-form expiration
  • Database-only duplicate logic

PRO

  • Explicit cookie enable per form
  • Custom expiration per form
  • Per-provider cookie isolation
  • Full cookie + database correlation

Performance Considerations

  • Single JS file
  • No polling beyond initial detection window
  • No AJAX
  • No external requests

Cookie creation happens once per form per browser. Runtime cost is negligible.


Conclusion

The Duplicate Killer cookie system is intentionally minimal, explicit, and deterministic. It exists to support duplicate submission prevention, not to replace proper backend validation.

This architecture ensures predictable behavior across WordPress form plugins while remaining privacy-conscious and performant.

Related Articles

Cross-Form Duplicate Protection in WordPress Forms

Cross-Form Duplicate Protection in WordPress Forms

A Complete Guide with Real-World Examples Duplicate form submissions are a common problem on WordPress websites. Most site owners focus on preventing duplicates inside a single form, but the real challenge often appears when multiple forms collect the same data across different pages. For example: If the same visitor submits their email in multiple places,…
WordPress Form POST Replay Protection: Why It Matters

WordPress Form POST Replay Protection: Why It Matters

When developers talk about duplicate form submissions in WordPress, the conversation usually focuses on users clicking the submit button twice. However, there is a less obvious technical issue that can cause the same form request to be processed multiple times: POST replay. POST replay occurs when the same HTTP request is delivered to the server…
WooCommerce Checkout Blocks vs Classic Checkout: Why Duplicate Killer FREE Works Only With Shortcodes

WooCommerce Checkout Blocks vs Classic Checkout: Why Duplicate Killer FREE Works Only With Shortcodes

If you enabled Duplicate Killer’s WooCommerce protection and it “does nothing”, you’re probably using WooCommerce Checkout Blocks. This is not a bug. It’s a technical difference between Classic Checkout (shortcode-based) and Checkout Blocks (block-based / Store API-based). Below is a simple explanation, plus examples and what you can do. Quick Summary Duplicate Killer FREE (WooCommerce)…
Choose the Unique Fields in WordPress Forms (How It Works)

Choose the Unique Fields in WordPress Forms (How It Works)

One of the most important steps in preventing duplicate submissions is choosing the right fields to validate. The Choose the unique fields in WordPress forms feature allows you to select exactly which form fields should be checked for duplicates before a submission is saved. Instead of blocking entire forms, you control which specific values must…
Limit Submissions by IP Address in WordPress (Free & PRO)

Limit Submissions by IP Address in WordPress (Free & PRO)

Repeated form submissions don’t always come from cookies or browser refreshes. Sometimes, users try to submit the same form multiple times from the same network. That’s where Limit submissions by IP address in WordPress becomes essential. This feature restricts form entries based on the visitor’s IP address for a defined number of days. What Does…
Unique Entries per User in WordPress: How to Use It

Unique Entries per User in WordPress: How to Use It

Duplicate form submissions are not always caused by multiple users.Sometimes, the same user submits the same form multiple times — intentionally or by mistake. The Unique entries per user in WordPress feature solves exactly this problem. Instead of blocking duplicate values globally, this option ensures that a single user cannot submit the same entry more…
What is the “Set Error Message” field in Duplicate Killer

What is the “Set Error Message” field in Duplicate Killer

The Set error message field allows you to define the message displayed to users when they try to submit a value that has already been submitted before. In simple terms, this message appears when Duplicate Killer detects a duplicate entry based on the unique field(s) you have configured (for example, email address, phone number, order…
WordPress Form Resubmits on Refresh: How to Prevent It

WordPress Form Resubmits on Refresh: How to Prevent It

A common WordPress forms issue is resubmission on refresh. A user submits a form, then refreshes the page (or returns using the back button) and the browser tries to submit the same POST request again. If your site accepts it, you get duplicate entries, duplicate emails, and duplicate leads. Why forms resubmit on refresh This…
Go to VerseLabWP homepage
© Copyright 2025 BITSTRUCT SRL. All Rights Reserved.