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

Slow websites create more Duplicate Orders than you think

Slow websites create more Duplicate Orders than you think

FAQ: Duplicate WooCommerce Orders ❓ Why do slow websites create duplicate WooCommerce orders? Customers often think checkout failed when pages load slowly or freeze temporarily. The natural reaction is to click the “Place Order” button again, creating repeated submissions. ❓ Does CAPTCHA stop duplicate WooCommerce orders? No. CAPTCHA mainly blocks bots and spam traffic. Real…
The Psychology Behind Duplicate Form Submissions

The Psychology Behind Duplicate Form Submissions

Most businesses think duplicate form submissions are caused by technical problems. But in reality, many duplicate submissions happen because of psychology. People click buttons emotionally, not logically. And when websites fail to provide reassurance, users naturally repeat actions. This is one of the biggest hidden reasons behind duplicate form submissions in WordPress. Why Human Psychology…
Why Users Submit Forms Multiple Times Even When They Don’t Want To

Why Users Submit Forms Multiple Times Even When They Don’t Want To

Duplicate form submissions are often treated as a technical problem. But in many cases, the real cause is human behavior. Most users do not intentionally submit the same form multiple times. They simply think the form did not work. This is one of the biggest reasons why duplicate form submissions happen on WordPress websites. Why…
Why Global Elementor Forms Create Hidden Duplicate Problems

Why Global Elementor Forms Create Hidden Duplicate Problems

Elementor duplicate forms can become a hidden problem when the same contact form is reused across multiple pages, templates, popups, or global sections. At first, everything looks normal. The form appears correctly.Leads arrive in your inbox.Visitors can submit without issues. But behind the scenes, your WordPress site may be treating similar forms as separate forms…
Why Form Spam and Duplicate Entries Are Different Problems

Why Form Spam and Duplicate Entries Are Different Problems

Duplicate entries and form spam are often confused by WordPress website owners. Many businesses install anti-spam plugins successfully, but duplicate entries can still damage CRM systems, analytics, and lead quality. And misunderstanding the difference often leads businesses to install the wrong type of protection. A CAPTCHA plugin may reduce bots successfully, but your CRM can…
Why Duplicate Leads Hurt Facebook Ads Optimization

Why Duplicate Leads Hurt Facebook Ads Optimization

Duplicate leads can seriously damage Facebook Ads optimization without most advertisers realizing it. When duplicate leads enter your CRM repeatedly, your campaigns may start optimizing using inaccurate conversion data and misleading audience signals. They change creatives.They increase budgets.They test new audiences. But many never realize the real problem is hidden inside their lead data. Duplicate…
The Hidden Cost of Duplicate Orders During Black Friday

The Hidden Cost of Duplicate Orders During Black Friday

Duplicate WooCommerce orders become a massive problem during Black Friday sales. Customers click checkout buttons multiple times, pages freeze under heavy traffic, and stores suddenly face duplicate payments, refunds, and inaccurate analytics. But for many WooCommerce stores, it also creates a hidden problem that quietly damages operations behind the scenes: duplicate orders. Most store owners…
How to Stop Duplicate WooCommerce Orders (Without Annoying Your Customers)

How to Stop Duplicate WooCommerce Orders (Without Annoying Your Customers)

Duplicate WooCommerce orders are more common than most store owners realize. A customer clicks the “Place Order” button twice because the page freezes for a second.Another refreshes the checkout page after payment.Someone on mobile taps repeatedly because they think nothing happened. Suddenly, you have: And the worst part? Most store owners don’t notice the problem…
Go to VerseLabWP homepage
© Copyright 2025 BITSTRUCT SRL. All Rights Reserved.